Title: [Plugin: Sort Query Posts] How to randomize ALL posts within a category
Last modified: August 20, 2016

---

# [Plugin: Sort Query Posts] How to randomize ALL posts within a category

 *  [DonnaMiller](https://wordpress.org/support/users/donnamiller/)
 * (@donnamiller)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-sort-query-posts-how-to-randomize-all-posts-within-a-category/)
 * 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/](http://wordpress.org/extend/plugins/sort-query-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Tubal](https://wordpress.org/support/users/tubal/)
 * (@tubal)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-sort-query-posts-how-to-randomize-all-posts-within-a-category/#post-2841935)
 * > 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](https://wordpress.org/support/users/sandipp/)
 * (@sandipp)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-sort-query-posts-how-to-randomize-all-posts-within-a-category/#post-2841936)
 * 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)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Sort Query Posts] How to randomize ALL posts within a category’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sort-query-posts.svg)
 * [Sort Query Posts](https://wordpress.org/plugins/sort-query-posts/)
 * [Support Threads](https://wordpress.org/support/plugin/sort-query-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/sort-query-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sort-query-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sort-query-posts/reviews/)

## Tags

 * [rand](https://wordpress.org/support/topic-tag/rand/)
 * [random order](https://wordpress.org/support/topic-tag/random-order/)

 * 2 replies
 * 3 participants
 * Last reply from: [Sandip Patil](https://wordpress.org/support/users/sandipp/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-sort-query-posts-how-to-randomize-all-posts-within-a-category/#post-2841936)
 * Status: not resolved