Skip to content

Instantly share code, notes, and snippets.

@benmay
Created June 6, 2012 00:42
Show Gist options
  • Save benmay/2879149 to your computer and use it in GitHub Desktop.
Save benmay/2879149 to your computer and use it in GitHub Desktop.
Modify the query on custom post type archives
add_filter( 'pre_get_posts','add_to_query' );
function add_to_query( $query )
{
if ( is_post_type_archive( 'listings' ) ):
$query -> set( 'orderby' , 'title' );
$query -> set( 'order' , 'asc' );
endif;
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment