Hi
I’m trying to remove 2 categories from the shop landing page using a PHP snippet from woocommerce.
https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/
The 2 product categories/slugs are events and workshops
The snippet is here:
/**
* Exclude products from a particular category on the shop page
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( ‘tax_query’ );
$tax_query[] = array(
‘taxonomy’ => ‘product_cat’,
‘field’ => ‘slug’,
‘terms’ => array( ‘workshops’ ), // Don’t display products in the workshops category on the shop page.
‘operator’ => ‘NOT IN’
);
$q->set( ‘tax_query’, $tax_query );
}
add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ );