3rd Apr '23
/
3 comments

Meta Box Relationship Slider in Bricks

Meta Box Relationship Slider in Bricks

This Pro tutorial provides the steps to modify the query parameter of a Bricks query loop to display slides of posts that are related to entries of a CPT via a Meta Box Relationship field.

Scenario:

CPT: featured-article

Meta Box Relationship: post-featured-articlesfrom featured-article to post

Requirement:Show the post title, post excerpt and a button linking to the post's permalink of all unique posts that are connected to the items of Featured Article CPT as slides in Bricks' nestable slider on a static Page (say, the homepage).

Step 1

Install and activate Meta Box and its AIO extensions.

Create the Featured Article CPT having a slug of featured-article.

Step 2

Create a Relationship titled say, "Post -- Featured Articles" from Featured Article to Post.

Do not tick "Reciprocal relationship".

Relationships in Meta Box are bi-directional by default unlike in ACF Pro which needs a separate plugin or code snippet.

Step 3

Create Featured Article CPT entries and select 1 or more related posts for each.

Step 3

Edit your homepage (or any other static Page/template) with Bricks.

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

Apply this Dynamic data condition on the Section to ensure that it gets output only if there's at least 1 post that has been selected as a related/connected item for any featured article.

{echo:bl_get_count_posts_related_to_featured_articles}

We shall define this custom function in a bit.

Delete Slides 2 and 3.

Enable query loop on Slide 1. Do not set any query parameters in the builder.

Add a Heading, Basic Text and Button elements inside the Slide 1.

Change Heading's text to:

{post_title}

Change Basic Text's text to:

{post_excerpt}

Change Button's text to Read more →

Link type: Dynamic Data

{post_url}

Step 4

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

Related Tutorials..

Pro
Conditionally outputting an element in a Query Loop based on date-type custom field

Conditionally outputting an element in a Query Loop based on date-type custom field

This Pro tutorial shows how to output an element in a Bricks' query loop only if the value of a date-type of custom field for…
Categories:
Pro
Dynamic Horizontal Posts Accordion in Bricks

Dynamic Horizontal Posts Accordion in Bricks

Update on 8 Sep 2024: You may want to follow the newer version that considers accessibility. Looking to make a Horizontal Image Accordion dynamic? This…
Posts Related by Current Post’s Terms in Bricks

Posts Related by Current Post’s Terms in Bricks

Showing other posts assigned to the same categories/tags/custom taxonomy terms as the current post.
Categories:
Pro
Meta Box Relationship Posts Filtered by a Taxonomy Term in Bricks

Meta Box Relationship Posts Filtered by a Taxonomy Term in Bricks

Updated on 17 Feb 2025 In the Inner Circle a user asks: Hello, I have a relationship made in metabox between two Post Types “Travel”…
Categories:
Pro
Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

In the BricksLabs Facebook group a user asks: I have a metaBox custom field called 'section_title' inside a clonable metabox group called 'about_section' How can…
Categories:
Tags:
Pro
Dynamic Source for Video Element in Bricks Using Meta Box Post Field

Dynamic Source for Video Element in Bricks Using Meta Box Post Field

This Pro tutorial provides the steps to set the source of a Bricks video element on single CPT pages to be the URL of a…
Categories: