Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove WooCommerce Product of specific category from shop page
function exclude_product_of_specific_category( $q ) {
if ( is_shop() ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'uncategorized' ), // write the slug of category to remove in between the ''
'operator' => 'NOT IN'
$q->set( 'tax_query', $tax_query );
add_action( 'woocommerce_product_query', 'exclude_product_of_specific_category' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment