Skip to content

Instantly share code, notes, and snippets.

@nickcernis
Created February 8, 2019 10:36
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 nickcernis/a8fd5f739169b5894ad285a6622500ea to your computer and use it in GitHub Desktop.
Save nickcernis/a8fd5f739169b5894ad285a6622500ea to your computer and use it in GitHub Desktop.
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