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

Related Tutorials..

Pro
ACF Repeater Row Count Condition in Bricks

ACF Repeater Row Count Condition in Bricks

This Pro tutorial provides the steps to output elements on single posts (of any post type) in Bricks only if a specific ACF Repeater-type of…
Categories:
Pro
Related Posts using ACF Post Object in Bricks

Related Posts using ACF Post Object in Bricks

Modifying the query loop to limit the posts to only related posts via an ACF Post Object custom field.
Categories:
Tags:
Pro
Outputting ACF Repeater’s Sub Fields

Outputting ACF Repeater’s Sub Fields

This Pro tutorial provides the code for printing custom HTML after looping through rows of a ACF Repeater (available in ACF Pro) that has a…
Categories:
Accessing ACF Repeater Sub Fields Programmatically in Bricks Query Loop

Accessing ACF Repeater Sub Fields Programmatically in Bricks Query Loop

It is possible to output sub field's values when a Bricks query loop's type has been set to a ACF Repeater without writing code. This…
Categories:
Pro
ACF Image Data in Bricks

ACF Image Data in Bricks

Displaying Alt text, Caption, Title and URL of an ACF image field for posts in a query loop.
Categories:
Tags:
How to create a dynamic infinite logo slider with ACF and Bricks

How to create a dynamic infinite logo slider with ACF and Bricks

This tutorial provides the builder settings, PHP & CSS codes that can be pasted in order to create an infinite logo slider in pure CSS…