Created
January 29, 2014 05:16
-
-
Save wpexplorer/8682239 to your computer and use it in GitHub Desktop.
Portfolio Post Type Archive & Taxonomy Order
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
function wpex_order_portfolio( $query ) { | |
// exit out if it's the admin or it isn't the main query | |
if ( is_admin() || ! $query->is_main_query() ) { | |
return; | |
} | |
// order portfolio archive by title in ascending order | |
if ( is_post_type_archive( 'portfolio' ) ) { | |
$query->set( 'order' , 'asc' ); | |
$query->set( 'orderby', 'title'); | |
return; | |
} | |
// order portfolio categories by title in ascending order | |
if ( is_tax( 'portfolio_category' ) ) { | |
$query->set( 'order' , 'asc' ); | |
$query->set( 'orderby', 'title'); | |
return; | |
} | |
} | |
add_action( 'pre_get_posts', 'wpex_order_portfolio', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment