Meta Box Image Advanced Field Images Slider in Bricks

Meta Box Image Advanced Field Images Slider in Bricks

In the previous ACF/Meta Box Gallery Images as Bricks Slider Using a Custom Query Type in Bricks tutorial we showed how a new query type can be created for feeding the images set in a Meta Box' Image Advanced field to a Bricks nestable slider.

This Pro tutorial provides step-by-step details of another way of accomplishing the same - this time using the bricks/posts/query_vars filter. We shall expand on the "Example: Loop images from Metabox.io Advanced Image Field of current post" on the filter's documentation page.

We are also going to ensure that the entire Section gets output only if the field is populated i.e., has at least 1 image.

Step 1

Create a field group having an Image Advanced type of custom field and attach it to your desired post type.

In this example, we created a field group called "Page Fields" having a page_gallery (field ID) "Image Advanced" type of field with the Location set to Page (page).

Step 2

Edit your posts (Pages in this example) and populate the custom field by selecting/uploading images for the Page Gallery.

Step 3

Edit your Page or the template that applies to all Pages with Bricks.

Manual instructions for setting up the Section are below. If you would like to import the Section by copy and paste, here's the JSON.

Add a Section and inside its Container, a Slider (Nestable) element.

Delete Slide 2 and Slide 3.

By default sliders take up 50vh height. You may want to click on the slider layer in the structure panel and enter auto for Height under OPTIONS.

Configure any other settings as needed for the arrows and pagination dots.

Select Slide 1.

Use query loop: Turn on.

Click the query/loop icon and set Post type to Media.

Order by: Post include order. This ensures that slide images appear in the same order as your images in the custom field.

Set Posts per page to a large number that images in your custom field will never typically exceed.

Add a Block inside Slide 1.

Padding on all sides: 2em

Max. width: 600

Typography → Color: #fff

Background color: rgba(0, 0, 0, 0.75)

Border on all sides: 4

Add a h3 heading inside the Block.

Change its text to:

{echo:bl_get_image_meta(title)}

You may want to rename this element in the structure panel to Title.

Add a Basic Text element below it, rename it to Caption and change its text to:

<strong>{echo:bl_get_image_meta()}</strong>

Add a Basic Text element below it, rename it to Description and change its text to:

{echo:bl_get_image_meta(description)}

Step 4

Apply a Dynamic data condition on the Section.

{echo:bl_is_image_advanced_empty(page_gallery)}

Replace page_gallery with your field ID.

Step 5

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

Get access to all 525 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to import custom posts with featured images and custom fields by fetching an API using a single AJAX call

How to import custom posts with featured images and custom fields by fetching an API using a single AJAX call

In this tutorial, we will import a list of movies - including images and custom fields - inside a custom post type by fetching a…
Categories:
Tags:
Pro
Slow Zoom Effect for Slides in Bricks

Slow Zoom Effect for Slides in Bricks

This Pro tutorial provides the steps to set up a slow zoom effect for slides of nestable slider element in Bricks. Step 1 Add a…
Categories:
Tags:
Pro
Outputting Only the First ACF Repeater Row in Bricks

Outputting Only the First ACF Repeater Row in Bricks

Updated on 12 Dec 2023 In the Bricks Facebook group a user asks: How can I display only the first entry from an ACF repeater?…
Pro
Setting a Bricks template for Parent pages

Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that…
Pro
Posts Published in the Last x Days in Bricks

Posts Published in the Last x Days in Bricks

Updated on 1 Feb 2024 This Pro tutorial shows how to limit the posts output by either the Posts element or a Query Loop in…