Support » Plugin: Sort Query Posts » [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/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tubal

    (@tubal)

    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

    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.