controlling random posts on catgory templates
-
Hello
I’ve got about 200 categories in a project I’m building and the number will increase as time goes on.
I have the following code on my homepage so that posts with the category name “all” appear there randomly on refresh, and I have made several category-slug.php templates for the same reason for some of the category pages.
<?php query_posts(array('orderby' => 'rand', 'category_name' => 'All', 'showposts' => 3)); if (have_posts()) : while (have_posts()) : the_post(); ?>
However I want to know if there’s a way I could dispense with the ‘category_name’ => ‘whatever the slug name is’ and the code automatically pic up the right category without me having to specify it so that I don’t have to make 200+ category-slug pages and keep on making them as time goes on.
I’ve tried adding just a category.php to my themes with the following code but it’s picking up any old category post rather than the category specific ones
<?php query_posts(array('orderby' => 'rand', 'showposts' => 3)); if (have_posts()) : while (have_posts()) : the_post(); ?>
- The topic ‘controlling random posts on catgory templates’ is closed to new replies.