WooCommerce Product Gallery via Query Loop?

I’m trying to create a Woocommerce product image gallery with a query loop following the steps in the link below with no luck. Any pointers?



Didn’t test your code, but the first thing to check is that you’ve registered the custom function with Bricks before using with the echo tag. Filter: bricks/code/echo_function_names – Bricks Academy

1 Like

Hi @ryanmvickerman ,

Seems like you are placing the {echo: woo_product_images} on the image element, but your function is returning an array of images. 1 Image should have 1 image ID only right, so your setup doesn’t make sense to me. Unless you place this echo function on Gallery image element.

Additionally, what is the Product Galleries query type? How do you create this query loop and what are the results? If you placed the image element inside the loop, you should need to have a function to retrieve the custom query results instead of woo_product_images.

By the way, if you want to retrieve the images attached to a product (WooCommerce product gallery field), you can create a Posts query and choose Media post type, then set {post_id} on the child of field. You should be able to retrieve the gallery images in the loop. Just use {post_id} on an image element inside the loop and you should be able to get what you want.

Regards
Jenn

Thanks for catching my error. I was trying to cobble together a solution not knowing that there was a simpler one. Thanks!

I tried your approach and I can’t seem to get it to work. Would you mind taking a quick look at the screenshots below? I know I’m missing something. Thanks you SO much in advance!

Hi @ryanmvickerman

Please send your admin credentials to help@bricksbuilder.io and include this forum thread URL as a reference.

Seems like your product gallery images didn’t attach to the product.

I will check on your site and provide a solution.

Regards,
Jenn