Sometimes you need to get product gallery images.
It is very easy and simple to get product gallery images.
There is wocommerce function get_gallery_attachment_ids()
,by using this function you will first get attachment id then by using this function wp_get_attachment_url()
you will get attachment url.
Put below code where you want to display your gallery images.
1 2 3 4 5 6 7 8 9 10 |
<?php global $product; $attachment_ids = $product->get_gallery_attachment_ids(); foreach( $attachment_ids as $attachment_id ) { $image_link = wp_get_attachment_url( $attachment_id ); echo '<img src="'.$image_link.'" />'; } ?> |