Looking for a code which could potentially help me get the list of gallery images present in product in woocommerce.

Need them so i can use them in a custom single page design for woocommerce product page.

3 s
3

<?php
$product_id = '14';
$product = new WC_product($product_id);
$attachment_ids = $product->get_gallery_image_ids();

foreach( $attachment_ids as $attachment_id ) 
    {
      // Display the image URL
      echo $Original_image_url = wp_get_attachment_url( $attachment_id );

      // Display Image instead of URL
      echo wp_get_attachment_image($attachment_id, 'full');

    }?>

Leave a Reply

Your email address will not be published. Required fields are marked *