Hi.
I am using grouped products. But the catalog is a dump of a heap of products linked to a group.
How do I hide linked products and their subcategories?
I use the code in function.php to hide the products:
function custom_hide_tags( $query ) {
$children = get_term_children( $query->queried_object_id , ‘product_tag’ );
$tax = $query->get( ‘tax_query’);
$tax[] = array(
‘taxonomy’ => ‘product_tag’,
‘field’ => ‘id’,
‘terms’ => ‘subcat’,
‘operator’ => ‘NOT IN’,
);
$query->set( ‘tax_query’, $tax );
}
add_action( ‘woocommerce_product_query’, ‘custom_hide_tags’);
On the screenshot, subcategory with hided products
Attachments:
You must be
logged in to view attached files.