WP for Wordpress

How to get woocommerece product gallery image url



In woocommerce it is easy to get product gallery image url, First of all just find the attachment id of the product that you want to find the gallery image url. $attachment_ids = $product->get_gallery_attachment_ids(); the $product is the global variable. To get each image link in a gallery, simply use a for loop with wp_get_attachment_url( $attachment_id ) function and pass attachment id As a argument
get_gallery_attachment_ids();

foreach( $attachment_ids as $attachment_id ) 
{
  echo $image_link = wp_get_attachment_url( $attachment_id );
}
?>
Now you get all the links of a product image galley and can use it with list item to form a Awesome carousal. Hope this will helpful :)


Responses

0 Respones to "How to get woocommerece product gallery image url"

Post a Comment

AddThis

 

Recent Comments

Return to top of page Copyright © 2014