18th Aug '23
/
12 comments

WooCommerce Product Gallery Images in Bricks Query Loop

Updated on 22 July 2024

Looking to output the images attached to Product gallery on a single WooCommerce product page in a Bricks query loop?

While it is possible to use the built-in "Product gallery" element or feed in the product gallery images to an "Image Gallery" element via this tutorial, you might want to use a query loop sometimes for more control.

This Pro tutorial shows how this can be achieved using a Media post type query. We shall also ensure that the Section gets output only if there is at least 1 product gallery image for any given product.

Step 1

Edit the template that applies to single Products with Bricks.

Add a Section and inside its Container, an optional "Product Gallery" Heading element and below that a Block element inside a Container.

Add an Image inside the Block.

Enable query loop on the Block.

Click the query icon and enable PHP query editor.

Paste:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 625 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Dynamic Date in Bricks Countdown Element

Dynamic Date in Bricks Countdown Element

As of Bricks 1.9.7.1, the built-in Countdown element's Date control does not support dynamic data. That is, it is not possible to set this date…
How to Remove Name and Website Fields in Bricks Comment Forms

How to Remove Name and Website Fields in Bricks Comment Forms

Updated on 14 Mar 2024 In the BricksLabs Facebook group a user asked: What is the best method to remove fields from the Bricks "Comments"…
Pro
Previous Two Posts in Bricks Query Loop

Previous Two Posts in Bricks Query Loop

This Pro tutorial shows how we can modify the parameters of a Bricks query to limit the posts to the previous two whilst cycling to…
How to create filters with IsotopeJS in Bricks (Part 1)

How to create filters with IsotopeJS in Bricks (Part 1)

This tutorial series will explore the IsotopeJS library's features inside the Bricks ecosystem.
Categories:
Pro
“Truncate text to these many characters” Bricks Control

“Truncate text to these many characters” Bricks Control

Bricks provides a :<number> dynamic data tag modifier that can be used to limit the amount of text by the specified number of words. Ex.:…
Create A Customizable AJAX Add To Cart Button In Bricks Builder

Create A Customizable AJAX Add To Cart Button In Bricks Builder

In Bricks, you can simply create an Add To Cart button from a dynamic data / function {woo_add_to_cart}. This button supports AJAX as well if…