pandasica
Member
Posted 1 year ago #
I want to display random posts of every category in my site...for example if you go to category SPORT you should see all posts from that category randomly, if you go to category MUSIC you should see all posts from that category randomly etc etc...i know how to do that for index page but i cant figure out how to do that for category page....THANKS IN ADVANCE
http://codex.wordpress.org/Function_Reference/query_posts
http://codex.wordpress.org/Function_Reference/WP_Query
Something like this in category.php before the loop [untested]:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$current_cat = get_query_var( 'cat' );
$args = array(
'orderby' => 'rand',
'cat' => $current_cat,
'paged' => $paged,
);
query_posts($args);
?>
pandasica
Member
Posted 1 year ago #
Thank you so much. i was looking for that. problem is solved!!!
thank you again.
You're welcome. Glad you got it resolved.
rajesh428
Member
Posted 1 year ago #
I want to implement this using thesis theme
Plz help me out
thnx in advance
supertouch
Member
Posted 1 year ago #
Works fine with me as well. BUT: Would it also be possible to use the random loop only for a specific category?
@supertouch: sure, just use a conditional category tag
supertouch
Member
Posted 1 year ago #
Got it! you made my day :)