Last active
July 27, 2022 12:49
-
-
Save woogists/75bf2f6b6535cd2581355e76e0b335bb to your computer and use it in GitHub Desktop.
[Frontend Snippets] Remove product content based on category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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..