6th Jun '24
/
4 comments

Meta Box Image Advanced Galleries using lightGallery in Bricks

Meta Box Image Advanced Galleries using lightGallery in Bricks

This Pro tutorial answers the question posted in the comments section of our previous Dynamic Galleries with Thumbnails and Captions in Lightbox using lightGallery in Bricks tutorial wherein the images to be shown in custom galleries using lightGallery are the ones in an Image Advanced-type of sub field inside a Group-type Meta Box field.

Each row of the Group field are to be shown as an accordion item for which we shall use BricksExtras' Pro Accordion element.

The benefit of using lightGallery over the built-in Gallery element of Bricks is that it gives us complete control with advanced features like captions inside the lightbox. When custom galleries are needed, this is the library to use.

Let's take an example where we have a tour Custom Post Type.

Tour Fields:

A specific Tour post being edited in the WP post editor:

After implementing the tutorial, on the front end:

After an image is clicked:

We shall ensure that the for each row of the Group field, gallery parent element is rendered only if the Image Advanced sub field is not empty.

Step 1

Install and activate BricksExtras.

Enable Pro Accordion module in its settings.

Step 2

Let's create a custom function that returns true or false depending on whether the Image Advanced sub field is populated or not.

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

Related Tutorials..

Pro
Current Post’s Terms in Bricks

Current Post’s Terms in Bricks

Updated on 15 Jan 2024 This Pro tutorial provides the steps to set up a grid of terms (like categories) that the current post is…
Pro
Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

This Pro tutorial provides the steps for setting up a cloneable Meta Box group query inside a CPT query in Bricks. Scenario: CPT: course Meta…
Categories:
Pro
Events grouped by months within years based on event date custom field value

Events grouped by months within years based on event date custom field value

How to output events grouped by years and months using three nested query loops in Bricks.
Categories:
Adding any Custom WP_Query loop to Bricks’ Query Loop

Adding any Custom WP_Query loop to Bricks’ Query Loop

Sometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…
Latest Featured Posts First in Bricks Query Loop (No Duplicates)

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

In the Bricks Facebook group a user asks: We can use AI to help unfreeze our brains sometimes or at least have it write the…
Categories:
Pro
Meta Box Related Project’s Featured Image URL on Single Reviews

Meta Box Related Project’s Featured Image URL on Single Reviews

Updated on 26 Jun 2025 In a recent website I worked on, a requirement was to get the URL of the featured image of a…