Created
March 5, 2025 11:35
-
-
Save plugin-republic/5fa7405cb4becc0f669813e04ea97563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?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