/**
* Hide specific product category on the shop page
*/
function my_custom_woocommerce_product_query( $defualt_query ) {
// Check if the Current page is shop page
if( is_shop() ){
// Add the default query into variable "taxonomy_query"
$taxonomy_query = (array) $defualt_query->get( 'tax_query' );
// add addtional query for Excluding specific product category
// For Ex.Videos
$taxonomy_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'videos' ),
'operator' => 'NOT IN'
);
$defualt_query->set( 'tax_query', $taxonomy_query );
}
}
add_action( 'woocommerce_product_query', 'my_custom_woocommerce_product_query' );
How to hide WooCommerce product category in shop page
Hiding specific product category on Shop page is simple by filtering woocommerce product query using this “woocommerce_product_query” filter.Copy and paste this code into your functions.php file.



















