Hi sotos.
You can use pre_get_posts
hook for modify the query and exclude the terms you want of a especific taxonomy (“product_cat” in this case).
Add the code below to your functions.php
:
add_action( 'pre_get_posts', 'pwbc_exclude_product_categories' );
function pwbc_exclude_product_categories( $query ) {
$categories_to_exclude = array( 'albums' );//this categories will be excluded (by slug)
$queried_object = get_queried_object();
if( is_a( $queried_object, 'WP_Term' ) && $queried_object->taxonomy == 'pwb-brand' && is_archive('product') ) {
//is brand page
$tax_query = array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $categories_to_exclude,
'operator' => 'NOT IN'
)
);
$query->set( 'tax_query', $tax_query );
}
}
??