Skip to content

Instantly share code, notes, and snippets.

@wpexplorer
Created January 29, 2014 05:16
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 wpexplorer/8682239 to your computer and use it in GitHub Desktop.
Save wpexplorer/8682239 to your computer and use it in GitHub Desktop.
Portfolio Post Type Archive & Taxonomy Order
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