Last active
January 11, 2019 13:20
-
-
Save squill/2ae0ab6820892e77bdccb18753592559 to your computer and use it in GitHub Desktop.
Hide Product Categories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_pre_get_posts_query( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
$tax_query[] = array( | |
'taxonomy' => 'product_cat', | |
'field' => 'slug', | |
'terms' => array( 'PUT THE CATEGORY TO HIDE HERE' ), // Don't display products in the this category on the shop page. | |
'operator' => 'NOT IN' | |
); | |
$q->set( 'tax_query', $tax_query ); | |
} | |
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment