Show posts in Category Archive Page in Random Order

I tried following code and it is working for me. Add this code in your functions.php file:

add_filter('pre_get_posts', 'pre_posts_order');
function pre_posts_order($wp_query){

  if( is_category() )   
    $wp_query->set( 'orderby' , 'rand' );
    
  return $wp_query;
}

Share This Article

Subscribe Membership Plan ($9.99/mo)

  • Get full access to all premium tutorials
  • Get Support for the posted content
  • Request for specific how-to tutorials
  • Cancel the subscription at anytime

Reader Interactions

Leave A Reply

Your email address will not be published. Required fields are marked *