Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exclude Genesis Portfolio taxonomies on the portfolio archive
<?php // omit this line from functions.php
add_filter( 'pre_get_posts', 'custom_remove_portfolio_taxonomy' );
function custom_remove_portfolio_taxonomy( $query ) {
if ( is_post_type_archive( 'portfolio' ) && $query->is_main_query() ) {
$tax_query = array(
array(
'taxonomy' => 'portfolio-type',
'field' => 'slug',
'terms' => array( 'type1', 'type2' ), // Change this to use the portfolio taxonomies you want to exclude.
'operator'=> 'NOT IN'
)
);
$query->set( 'tax_query', $tax_query );
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment