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 Bricks single property CPT template, we can add an Image Gallery element and select our ACF field to display a grid or masonry of the selected images for each property.

Now the requirement is to randomize the order of these images and output only a specific number of them, like 3.

This Pro tutorial shows how this can be done by creating a custom function that takes a field name and the number as parameters and returns an array of image IDs. We shall use this function as the source in the Image Gallery element.

Step 1

Add the following in child theme's functions.php or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro