0
votes

I Have done some searching around excluding a product category from related products in Woocommerce. But all the answers to this problem relate to excluding completely categories and/or tags.

How do I hook into woocommerce_get_related_products to exclude a specific product category?

I would like to exclude my "Sold" product category from displayed related products.

1

1 Answers

-1
votes

Try this code,

add_action( 'wp', 'vn_remove_related_products' );
function vn_remove_related_products() {
  if ( is_product() && has_term( array('workshops', 'events'), 'product_cat' ) ) {
        remove_action( 'woocommerce_after_single_product_summary', 
'woocommerce_output_related_products', 20 );
  }
}

Hope this will helps you.

For more details visit

remove a category from related products

Woocommerce exclude specific category products from related products