Hide Products by Category in the Shop page of WooCommerce
Copy the code below and paste it in functions.php
add_action( 'woocommerce_product_query', 'hide_products_in_shop' );
function hide_products_in_shop( $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 );
}
Support WeHelpCode by subscribing to our YouTube Channel