• Resolved keithbiomed

    (@keithbiomed)


    I added 1 gallery image to my product page, but then decided I didn’t want it so removed it so the gallery should be empty but the main product image thumbnail still appears in the gallery, how do I completely empty it and remove that thumbnail? see image in comparison to another product page: https://app.screencast.com/NykIy0vIIGiDw

    I have cleared my cache and deleted transients etc. etc. nothing works.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    add_filter('woocommerce_single_product_image_thumbnail_html', 'ahirwp_remove_featured_image', 10, 2);
    function ahirwp_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;
    }

    Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

    Thanks
    Ahir

    Thread Starter keithbiomed

    (@keithbiomed)

    Thank you! However the image seems to have gone away on it’s own after an hour. I will keep this handy in case it happens again thank you!

    Thank you for reaching out to us. I believe I have provided a solution to the issue you were facing. If the solution is working fine for you, I kindly request you to mark this thread as resolved. If you have any more questions or need further assistance, please don’t hesitate to contact here.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to remove main product image from gallery when there are no gallery images’ is closed to new replies.