Opens in a new tab
27th Mar '23
/
0 comments

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

Related Tutorials..

Removing Action/Filter Inside a Plugin’s Namespaced Class Constructor

Removing Action/Filter Inside a Plugin’s Namespaced Class Constructor

Recently worked with a friend figuring out how to remove/undo/cancel an add_action() line that's inside a plugin's constructor inside a PHP Class with the file…
Categories:
Tags:
Pro
Post Data for the Current User in Bricks with Meta Box

Post Data for the Current User in Bricks with Meta Box

How to configure a query loop to output the post data of the SalesRep CPT associated with the current user.
Categories:
How to sync two nestable sliders in Bricks

How to sync two nestable sliders in Bricks

In this tutorial, we'll learn how to sync two nestable sliders in Bricks: one will be the main slider and the other one will be…
Categories:
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
Categories: