Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter the portfolio category in York
function york_filter_portfolio_category( $args ) {
if ( is_archive('post') OR is_category() OR is_tag() ) {
$post_type = 'post';
} else {
$post_type = 'portfolio';
}
// Pull pagination count setting from the Customizer.
$portfolio_posts_count = get_theme_mod( 'portfolio_posts_count', -1 );
// Pull pagination from the reading settings.
$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
return $args = array(
'post_type' => $post_type,
'order' => 'ASC',
'orderby' => 'menu_order',
'paged' => $paged++,
'posts_per_page' => $portfolio_posts_count,
'tax_query' => array(
array(
'taxonomy' => 'portfolio_category',
'field' => 'slug',
'terms' => apply_filters( 'ava_portfolio_category_filter', 'design' ),
),
),
);
}
add_filter( 'york_portfolio_args', 'york_filter_portfolio_category' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment