DonnaMiller
Member
Posted 11 months ago #
I'm using the plugin to randomize posts within each category. What I've noticed is that it actually doesn't randomize all posts in a category, but rather shuffles the order of the posts that appear on each archive page. Is there a way to get it to randomize ALL posts within a category so that different posts can appear on the first archive page?
http://wordpress.org/extend/plugins/sort-query-posts/
Tubal
Member
Plugin Author
Posted 11 months ago #
but rather shuffles the order of the posts that appear on each archive page.
Yes, that's the intended behavior.
Is there a way to get it to randomize ALL posts within a category so that different posts can appear on the first archive page?
Not with this plugin.
Regards,
Túbal
Sandip Patil
Member
Posted 11 months ago #
Try Below code..
1. Select the post from category:
$args = array('cat' => $category_id,'post_status' =>'publish','posts_per_page'=>-1,'orderby' => 'post_date','order'=>'DESC');
$random_posts_arr = query_posts($args);
2. shuffle or randomize the post array...
$post_arr = shuffle($random_posts_arr);
3. Then traverse the post array ($post_arr) to show the post data (title, link, image, date)