Skip to content

Instantly share code, notes, and snippets.

@stuartduff
Created March 18, 2015 12:10
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 stuartduff/9579eebf6bc542e20ee5 to your computer and use it in GitHub Desktop.
Save stuartduff/9579eebf6bc542e20ee5 to your computer and use it in GitHub Desktop.
Projects Randomise Project Archive & Category Output
function custom_projects_randomise_project_output( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_post_type_archive( 'project' ) || is_tax( 'project-category' ) ) {
$query->set( 'order', 'ASC' );
$query->set( 'orderby', 'rand' );
return;
}
}
add_action( 'pre_get_posts', 'custom_projects_randomise_project_output', 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment