Created
June 6, 2012 00:42
-
-
Save benmay/2879149 to your computer and use it in GitHub Desktop.
Modify the query on custom post type archives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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