I am trying to make products with a certain tag disappear completely from the store, including when customers are browsing categories.
In another question I found this function that help me hide products on the shop page, which is great.
function exclude_specific_tag( $q ) {
if (is_shop()){
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'terms' => array( 'special' ), // tag name to hide ''
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
}
add_action( 'woocommerce_product_query', 'exclude_specific_tag' );
Now I need to hide that certain tag from product-categories. The goal is to hide these products with the tag completely from the store, unless I show them in a specific page or post.
Any help and answers are greatly appreciated.