Remove featured image from the WooCommerce gallery

There is only 2 arguments for woocommerce_single_product_image_thumbnail_html filter hook.

So you have to change a little bit your code to avoid the error, this way:

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;
}

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


References for filter hook woocommerce_single_product_image_thumbnail_html:

  • woocommerce templates: single-product/product-image.php
  • woocommerce templates: single-product/product-thumbnails.php