Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created March 5, 2025 11:35
Show Gist options
  • Save plugin-republic/5fa7405cb4becc0f669813e04ea97563 to your computer and use it in GitHub Desktop.
Save plugin-republic/5fa7405cb4becc0f669813e04ea97563 to your computer and use it in GitHub Desktop.
<?php
/**
* Hide products from specific category on shop page
* Update line 13 with category slugs to hide
*/
function pr_product_query_tax_query( $tax_query, $query ) {
if( ! is_shop() ) return $tax_query;
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'hoodies' ); // Update slugs here
'operator' => 'NOT IN',
);
return $tax_query;
}
add_filter( 'woocommerce_product_query_tax_query', 'pr_product_query_tax_query', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment