Skip to content

Instantly share code, notes, and snippets.

@Luminus
Created December 5, 2017 05:36
Show Gist options
  • Save Luminus/cad54c9afca38aab4f849458c15c0b7f to your computer and use it in GitHub Desktop.
Save Luminus/cad54c9afca38aab4f849458c15c0b7f to your computer and use it in GitHub Desktop.
Remove Related Products from the Single Product Page for Products in a Specific Category
<?php
add_action( 'wp', 'vn_remove_related_products' );
function vn_remove_related_products() {
// replace 'accessories' with the slug for your product category
if ( is_product() && has_term( 'accessories', 'product_cat' ) ) {
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
}
}
@johnnyray22
Copy link

Thanks much for that snippet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment