Created
July 18, 2017 16:56
-
-
Save richtabor/27f47a92617ffb53e288f8aee47213c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Exclude the featured image from appearing in the product gallery, if there's a product gallery. | |
* | |
* @param array $html Array of html to output for the product gallery. | |
* @param array $attachment_id ID of each image variables. | |
*/ | |
function ava_woocommerce_remove_featured_image( $html, $attachment_id ) { | |
global $post, $product; | |
// Get the IDs. | |
$attachment_ids = $product->get_gallery_image_ids(); | |
// If there are none, go ahead and return early - with the featured image included in the gallery. | |
if ( ! $attachment_ids ) { | |
return $html; | |
} | |
// Look for the featured image. | |
$featured_image = get_post_thumbnail_id( $post->ID ); | |
// If there is one, exclude it from the gallery. | |
if ( $attachment_id == $featured_image ) { | |
$html = ''; | |
} | |
return $html; | |
} | |
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'ava_woocommerce_remove_featured_image', 10, 2 ); |
Its working fine for woocommerce default slider which is flexslider.
But in my case i am using other product slider which is based on slick slider. So for me its not working.
Any suggestion?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I try too use your code but for me its only disable image in thumbnail.
How to remove feature IMAGE from main gallery also ?
regards
Rafael