How to Wordpress Tricks

How to get Woocommerce Product Gallery image URLs?

Wordpress Themes and Plugins

Sometimes, when you work with custom solutions of WordPress and WooCommerce, you may need to get a product image gallery. If you need to extract via php the WooCommerce product gallery images you can use the following code.

    global $product;

    $attachment_ids = $product->get_gallery_attachment_ids();

    foreach( $attachment_ids as $attachment_id ) {
        echo $image_link = wp_get_attachment_url( $attachment_id );


Leave a Comment

You may also like