View Single Post
Old 06-25-2013, 05:16 AM  
vdbucks
Monger Cash
 
Industry Role:
Join Date: Jul 2010
Posts: 2,773
Quote:
Originally Posted by nexcom28 View Post
I have several categories, one of them being for example 'news'. I am wanting to random the posts within this category only.

Currently all posts in all categories are random.

Thanks
I think the best way for that then would be to copy category.php to category-news.php (make sure the "news" portion matches the category slug), or to category-ID.php (where ID = the news category ID). You can find the info you need in wp-admin -> Posts -> Categories.

Then, just remove the "query_posts($query_string."&orderby=rand");" from the base category.php file, and you should be good to go.

And then, for any other categories you may want to display random posts for in the future, simply copy category-news.php (or category-ID.php) to category-slug.php (or category-ID.php, again specifying the numeric ID of said category).

More info here: http://codex.wordpress.org/Category_Templates
vdbucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote