How To Remove the Featured Image from WooCommerce Product Gallery

Product Gallery on single product pages in WordPress include the product’s featured image by default. If you are looking to exclude it so only the gallery images are shown, add the following in child theme‘s functions.php or a code snippets plugin:

add_filter( 'woocommerce_single_product_image_thumbnail_html', function ( $html, $post_thumbnail_id ) {
	global $product;

	if ( $post_thumbnail_id === $product->get_image_id() )
		$html = '';

	return $html;
}, 10, 2 );

Reference

/wp-content/themes/bricks/includes/woocommerce/elements/product-gallery.php

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

1 comment

  • Hi, thanks, this does indeed remove the featured image. However, on a variable product, the main gallery image no longer swaps out when selections are made. The thumbnail below the main image still does though.

Leave your comment