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

Related Tutorials..

Pro
Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

On product pages, we show all the FAQs associated with the current WooCommerce product's product categories.
Categories:
Pro
Sub Field Value from the Last ACF Repeater Row in Bricks

Sub Field Value from the Last ACF Repeater Row in Bricks

Getting the value of a specific sub field of an ACF Pro‘s Repeater field and output in the query loop.
Categories:
Tags:
Pro
ACF User Field Bricks PHP Query

ACF User Field Bricks PHP Query

In the Bricks Facebook group a user asks: my end goal was to create a set of cards that would display the Users that are…
Categories:
Pro
Custom Dynamic Data Tags for ACF Field Label, Prefix and Suffix in Bricks

Custom Dynamic Data Tags for ACF Field Label, Prefix and Suffix in Bricks

Bricks lacks built-in dynamic tags for ACF field labels, prefixes, and suffixes. This tutorial shows how to add them using custom dynamic tags.
Categories:
Pro
Programmatically populating ACF field values in WordPress

Programmatically populating ACF field values in WordPress

An example of how to set the values of a Select-type field with the names and labels of all public post types.
Categories:
Pro
ACF Repeater sub field value dynamic data condition in Bricks

ACF Repeater sub field value dynamic data condition in Bricks

This Pro tutorial provides the steps to output an element on single posts (can be of any post type) only if a specified ACF (Pro)…