Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active July 27, 2022 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogists/75bf2f6b6535cd2581355e76e0b335bb to your computer and use it in GitHub Desktop.
Save woogists/75bf2f6b6535cd2581355e76e0b335bb to your computer and use it in GitHub Desktop.
[Frontend Snippets] Remove product content based on category
/**
* Remove product content based on category
*/
add_action( 'wp', 'remove_product_content' );
function remove_product_content() {
// If a product in the 'Cookware' category is being viewed...
if ( is_product() && has_term( 'Cookware', 'product_cat' ) ) {
//... Remove the images
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
// For a full list of what can be removed please see woocommerce-hooks.php
}
}
@wildtraveller
Copy link

Thank you! Can you please advise if I would like to remove the image for example for 2 categories, instead of Cookware, there would be Cookware and Silverware, how to write that snippet? I have tried but as not a programmer than cant figure out the right way..

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