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 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.
How to create filters with IsotopeJS in Bricks (Part 2): Dynamic Image Galleries

How to create filters with IsotopeJS in Bricks (Part 2): Dynamic Image Galleries

This tutorial series will review how to create a dynamic filterable image gallery using the IsotopeJS library‘s features in Bricks. Requirements Create a custom taxonomy for your…
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
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: