Created
June 18, 2019 11:23
-
-
Save vagelisp/aae849208e7058087586fec32167efb7 to your computer and use it in GitHub Desktop.
functions
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
/** | |
* Exclude products from a particular category on the shop page | |
*/ | |
function hide_products_in_unc( $q ) { | |
$tax_query = (array) $q->get( 'tax_query' ); | |
$tax_query[] = array( | |
'taxonomy' => 'product_cat', | |
'field' => 'slug', | |
'terms' => array( 'uncategorized' ), | |
'operator' => 'NOT IN' | |
); | |
$q->set( 'tax_query', $tax_query ); | |
} | |
add_action( 'woocommerce_product_query', 'hide_products_in_unc' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment