15th Jul '24
/
0 comments

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

Related Tutorials..

Pro
Oxygen’s Focus Section in Bricks

Oxygen’s Focus Section in Bricks

These are the steps to implement Focus Section, an Oxygen’s composite element, in Bricks.
Categories:
Width and Height of Mobile Hamburger Toggle in Bricks

Width and Height of Mobile Hamburger Toggle in Bricks

Looking to change the size of Bricks hamburger toggle in the mobile menu? The default width value of 20px can be changed by selecting the…
Categories:
Pro
Meta Box Taxonomy Field’s Image Value in Posts

Meta Box Taxonomy Field’s Image Value in Posts

In a project I am currently working on, the requirement is to show the image of an "Image Advanced" type attached to a taxonomy in…
Categories:
Tags:
Pro
How to Combine Multiple Menus into Bricks’ Mobile Menu

How to Combine Multiple Menus into Bricks’ Mobile Menu

Bricks' native 'Nav Menu' element comes with a built-in mobile menu, which shrinks the menu down to a menu toggle button to open an offcanvas…
Categories: