Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created April 12, 2016 13:06
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 billerickson/a9c4c5228ff3ea573e80872401755671 to your computer and use it in GitHub Desktop.
Save billerickson/a9c4c5228ff3ea573e80872401755671 to your computer and use it in GitHub Desktop.
<?php
/**
* Exclude 'hidden' taxonomy from portfolio
*
*/
function be_portfolio_query( $query ) {
if( $query->is_main_query() && $query->is_post_type_archive( 'portfolio' ) && ! is_admin() ) {
$tax_query = array(
array(
'taxonomy' => 'portfolio-category',
'field' => 'slug',
'terms' => array( 'hidden' ),
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'pre_get_posts', 'be_portfolio_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment