2nd Oct '25
/
0 comments

Limiting the Number of Images in Bricks Image Gallery Element

In the recent Bricks Image Gallery element with Image limit tutorial we showed how the built-in 'Image Gallery' element of Bricks can be duplicated and modified to only render a specific number of images. This method works regardless of the source of the images in the element - static or dynamic.

When the source is dynamic, there is a simpler way to limit the number of gallery images though - the render_tag() function in Bricks. This Pro tutorial provides the details.

Step 1

Using your favorite custom fields plugin add a field group for your post type having a field for multiple image upload/selection. Ex.: Gallery when using ACF or Image Advanced when using Meta Box.

Create/edit posts/Pages and select/upload the images for each.

Edit the Page/template with Bricks.

Add an Image Gallery element inside a Section's Container.

Click the power icon in the Images control and select your custom field. Copy the dynamic tag since we will use it in the next step (without the curly braces).

Step 2

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Merging ACF Gallery Images with Featured Image in Bricks

Merging ACF Gallery Images with Featured Image in Bricks

Updated on 12 Mar 2025 In the Bricks Facebook group a user asks: Merging images from different fields into a single gallery Hi, I have…
Categories:
Pro
Button to Open Bricks Gallery

Button to Open Bricks Gallery

How to trigger a click on the first image of a gallery in Bricks when a button is clicked.
Categories:
Pro
Configuring Image Gallery dynamic source in Bricks

Configuring Image Gallery dynamic source in Bricks

Let's say you have a custom field created with ACF Pro of the type Gallery called "Property Gallery" for posts of "Property" CPT. In the…
Pro
HappyFiles Folder Images via Meta Box Taxonomy Field in Bricks Image Gallery

HappyFiles Folder Images via Meta Box Taxonomy Field in Bricks Image Gallery

How to set the source of Bricks’ Image Gallery element on a post to images in the selected HappyFiles Folder(s) via a Meta Box Taxonomy…
Pro
ACPT Gallery Field Query Loop in Bricks

ACPT Gallery Field Query Loop in Bricks

How we can output images from ACPT‘s Gallery field for posts as a grid using a query loop.
Categories: