Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.