This is a Developer level doc. If you are unfamiliar with code and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our Support Policy.
functions.php
file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php
file, as this will be wiped entirely when you update the theme.
The following code will remove product images on single product pages within the ‘Cookware’ 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 | |
} | |
} |