This Pro tutorial provides the steps to set up multiple galleries per page in Bricks using Meta Box cloneable Group field having an Image Advanced sub field.
When editing a Page:
After implementing the tutorial, on the front end:
Update: Added instructions for showing custom gallery titles.
Step 1
Install and activate Meta Box and Meta Box AIO plugins.
Import this field group or set it up for Pages like this:
Step 2
Edit your Pages. Add as many galleries as needed for each and upload/select images.
Step 2
Edit the template that applies to all the Pages with Bricks.
Copy this JSON and paste to import the Section.
We have applied a Dynamic data condition to the Section to ensure that it gets output only if there is at least 1 page gallery for the current Page.
The first Heading's text is set to "Page". We are going to append " Galleries" or " Gallery" to it conditionally based on the number of galleries.
"Use query loop" is ticked for the Block and the Query Type set to MB Group: Page Galleries
.
Image Gallery element's source has been set to:
{echo:bl_get_page_gallery}
where bl_get_page_gallery()
is a custom function that we are going to define in the next step.
The text of Heading above the Image Gallery is set to:
Gallery {echo:bl_get_loop_index}
bl_get_loop_index()
is a custom function that we are going to define in the next step.
This will print "Gallery 1", "Gallery 2" headers - as many as the number of page galleries.
Step 3
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