In WooCommerce possiamo escludere una categoria di prodotti dalla pagina del negozio.
La soluzione รจ la seguente:
function my_custom_pre_get_posts_query( $q ) {
if( is_shop() ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'category-slug' ),
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
}
add_action( 'woocommerce_product_query', 'my_custom_pre_get_posts_query' );