Answer the question
In order to leave comments, you need to log in
How to hide the first image in the product gallery?
How to disable the display of the first image in the product gallery in WooCommerce?
Tried two options, both don't work
add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_product_main_image', 2);
function remove_product_main_image($html) {
global $post;
$thumbnail = '#(<div data-thumb="' . get_the_post_thumbnail_url( $post->ID, 'shop_thumbnail' ) . '" class="woocommerce-product-gallery__image">).*?(</div>)#';
$html = preg_replace( $thumbnail, '', $html );
return $html;
}
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question