4th Mar '25
/
0 comments

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 a Gallery field created in ACF and a standard Featured Image field. Is it possible in Bricks to display images from both fields as a single gallery using dynamic data, for example, in a carousel element?

This Pro tutorial shows how render_tag() method of Bricks Providers PHP class can be used to get the image IDs of selected images of the specified ACF Gallery field and combine these with the current post's featured image ID and supplied as the dynamic data source for Bricks elements like Image Gallery.

We shall also add optional randomize and image count arguments in our custom function so the images can be shown in random order and the number of images to be shown can be set, if needed.

This also works with Meta Box and JetEngine and any other custom fields plugin that Bricks integrates with (see the list here) with minor changes.

Single Tutorial Purchase Option

Lifetime access to this single tutorial can be purchased for $20 here.

Step 1

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

Related Tutorials..

Pro
CPT Submenu Items in ACF Pro Options Admin Menu

CPT Submenu Items in ACF Pro Options Admin Menu

This Pro tutorial provides the steps to add links to admin pages under an Options page created with ACF Pro. All code mentioned in this…
Pro
Conditionally Hiding Bricks Filters based on Select Filter Value

Conditionally Hiding Bricks Filters based on Select Filter Value

How show or hide Bricks' filter based on the selection made by another filter.
Categories:
Tags:
Pro
Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

This Pro tutorial covers how posts of a Bricks query loop can be filtered to show only the ones whose true / false or checkbox…
Categories:
Tags:
Pro
ACF Date Field Value Custom Format in Bricks

ACF Date Field Value Custom Format in Bricks

In the Bricks forum, a user asks: Hi there, I am setting up an events calendar using bricks. In some circumstances I would like to…
Categories:
Tags: