Hide Featured image specific woocommerce categories

Hi,

I have managed to get the featured image show on the catalogue and when you click into the product page the gallery photo is the main photo.

This is the code i used:

add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 2);
function remove_featured_image($html, $attachment_id ) {
global $post, $product;

$featured_image = get_post_thumbnail_id( $post->ID );

if ( $attachment_id == $featured_image )
    $html = '';

return $html;
}

Is there a way I specify certain categories?

Hi Tim,

Just to make sure that we are on the same page, this is a customization request and outside of our support scope. We will help you to get started but the implementation of the feature is on your shoulders.

A trick that you can use is to utilize the Woocommerce specific Conditional Tag. To read more about Woocommerce conditional tags please check the link below:

A conditional tag that I think might be of use here is:

is_product_category( array( 'shirts', 'games' ) )

The PHP Array is the list of your Product Category slugs that you want to enforce your code on.

You will need to use if to determine if the category page is what you want, such as:

if (is_product_category( array( 'shirts', 'games' ) )) {
}

You can add your code inside the if statement. I am not sure how you implement the Feature Image thing but this is the way you can limit the code only for specific product categories.

If you can not use the information we provided, we suggest that you contact a developer to do the customization for you.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.