Skip to content

Instantly share code, notes, and snippets.

@frankschrijvers
Last active July 17, 2021 04:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankschrijvers/4346dfac23d5d09bd9add736a8a620b3 to your computer and use it in GitHub Desktop.
Save frankschrijvers/4346dfac23d5d09bd9add736a8a620b3 to your computer and use it in GitHub Desktop.
Add gallery thumbs to woocommerce shop page
//* Add gallery thumbs to woocommerce shop page
add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs', 5);
function wps_add_extra_product_thumbs() {
if ( is_shop() ) {
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
echo '<div class="product-thumbs">';
foreach( array_slice( $attachment_ids, 0,3 ) as $attachment_id ) {
$thumbnail_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail' )[0];
echo '<img class="thumb" src="' . $thumbnail_url . '">';
}
echo '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment