Last active
March 12, 2023 18:33
-
-
Save voronkovich/4de44c07ad79a50b2ee117331249647e to your computer and use it in GitHub Desktop.
WooCommerce: remove repeated featured image from product gallery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('woocommerce_single_product_image_thumbnail_html', 'app_remove_repeated_featured_image_from_product_gallery', 10, 2); | |
function app_remove_repeated_featured_image_from_product_gallery( $html, $attachment_id ) { | |
global $product; | |
static $counter = 0; | |
if ( get_post_thumbnail_id( $product->get_id() ) == $attachment_id ) { | |
$counter++; | |
if ( $counter > 1 ) { | |
return ''; | |
} | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment