Meta Box/ACF Images Staggered Grid Gallery in Bricks

This Pro tutorial provides the steps to show images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.

We shall write a custom function that builds an array with IDs of images like this:

  • first image from the full width images
  • first two images from the half width images
  • second image from the full width images
  • third and fourth images from the half width images

and so on...

This function will then be set as the source of images for the Bricks' Image Gallery element.

After implementing the tutorial:

Step 1

Create a field group for your post type (page in this example) having:

If using ACF

two 'Gallery' fields

Set the Return Format to Image ID for both fields.

If using Meta Box

two 'Image Advanced' fields

Step 2

Edit your posts (Pages in this example) and populate the fields.

ACF:

Meta Box:

Step 3

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

If using ACF:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Conditional Output Based on ACF Date Field in Bricks

Conditional Output Based on ACF Date Field in Bricks

Updated on 1 Aug 2024 Looking to have a Section or other elements in Bricks rendered on the frontend only if today's date is before…
Categories:
Custom Function for ACF Link Field

Custom Function for ACF Link Field

How to output the label of an ACF link field through Dynamic Data.
Categories:
Tags:
Pro
Events grouped by Event Date custom field in Bricks

Events grouped by Event Date custom field in Bricks

This Pro tutorial for Bricks users provides the steps to output posts of an event custom post type dynamically grouped by the value of their…
Categories:
Pro
Sticky Scrolling in Bricks Builder

Sticky Scrolling in Bricks Builder

Updated on 22 Apr 2024 This Pro tutorial provides the steps to fix elements in the viewport i.e., make them sticky while adjacent content in the section…
Categories:
Tags:
Pro
ACPT Gallery Field Query Loop in Bricks

ACPT Gallery Field Query Loop in Bricks

How we can output images from ACPT‘s Gallery field for posts as a grid using a query loop.
Categories: