Random images from ACF Options Gallery in Bricks

This Pro tutorial provides the steps to output images from an ACF Gallery-type custom field in a Bricks query loop randomly with each image appearing only once with the remaining filled by a fallback image.

We shall use PHP sessions to ensure that any given image from the gallery is used only once.

Options page:

Options page field group:

Gallery field populated with images:

After implementing the tutorial:

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro