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..

Pro
How to Modify Products Element Query in Bricks to Output Child Products

How to Modify Products Element Query in Bricks to Output Child Products

This Pro tutorial provides the steps to limit WooCommerce products output by Bricks' Products element on single product pages to only the children of the…
Appending WooCommerce Endpoint Names To My account Page Titles in Bricks

Appending WooCommerce Endpoint Names To My account Page Titles in Bricks

Adding the WooCommerce endpoint names, “Orders”, “Downloads” after the WooCommerce ‘My account’ Page’s title text at the various endpoint URLs.
Categories:
Pro
Similarly Priced WooCommerce Products Bricks Query Loop

Similarly Priced WooCommerce Products Bricks Query Loop

How to show products priced within a percentage of the current single product's price.
Categories:
Pro
WooCommerce Product Carousel in Bricks

WooCommerce Product Carousel in Bricks

How to set up a carousel that shows WooCommerce products with the product title, price and Add to Cart button for each.
Categories:
Pro
Top-Level Product Categories in Bricks

Top-Level Product Categories in Bricks

How to show top-level WooCommerce product categories in Bricks using a query loop.
Categories:
Create A Customizable AJAX Add To Cart Button In Bricks Builder

Create A Customizable AJAX Add To Cart Button In Bricks Builder

In Bricks, you can simply create an Add To Cart button from a dynamic data / function {woo_add_to_cart}. This button supports AJAX as well if…