Skip to content

Instantly share code, notes, and snippets.

@rodgerthat
Created October 8, 2012 21:02
Show Gist options
  • Save rodgerthat/3854960 to your computer and use it in GitHub Desktop.
Save rodgerthat/3854960 to your computer and use it in GitHub Desktop.
Change / Modify Default WordPress Query from functions.php using pre_get_posts
/*
* Mod Default Query
*
* get at the default query and make your changes before the template ( or whatever is run )
*
*/
function ahso_default_query_mods( $query ) {
// use conditional tags
if ( is_tax('work_cat') ) {
// once you've got the query_vars, limit == sky.
$query->query_vars['order'] = 'ASC';
$query->query_vars['orderby'] = 'menu_order';
}
}
add_action( 'pre_get_posts', 'ahso_default_query_mods' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment