6th Oct '23
/
2 comments

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

Get access to all 610 Bricks code tutorials with BricksLabs Pro

2 comments

  • Javiera

    Thank you so much!

  • 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

 

Related Tutorials..

Side-by-side WooCommerce Quantity and Add to Cart in Bricks

Side-by-side WooCommerce Quantity and Add to Cart in Bricks

Looking to position the quantity input field and Add to cart button next to each other instead of one below the other in Bricks? Add…
Categories:
Is WooCommerce Cart Empty Condition in Bricks

Is WooCommerce Cart Empty Condition in Bricks

Updated on 5 Nov 2024 Looking to conditionally render an element depending on whether the user's cart is empty or not when using WooCommerce? Add…
Pro
Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

On product pages, we show all the FAQs associated with the current WooCommerce product's product categories.
Categories:
Condition based on WooCommerce Product Attributes in Bricks

Condition based on WooCommerce Product Attributes in Bricks

How to display elements only when a specific WooCommerce product attribute is selected.
Categories: