Skip to content

Instantly share code, notes, and snippets.

@generatepress
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/bcee6fc33a22e578885c to your computer and use it in GitHub Desktop.
Save generatepress/bcee6fc33a22e578885c to your computer and use it in GitHub Desktop.
Make category posts display randomly
add_action( 'pre_get_posts', 'generate_random_category_posts', 100 );
function generate_random_category_posts( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'orderby', 'rand' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment