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