4th Feb '25
/
2 comments

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” AND “Programs”

When I am in post Type “Travel”, I want to query the relationship, so I only see the “Program” posts, filtered by a term=”long-travel” of a taxonomy “travel-types”

I think ACF has something to do this, but in Meta Box i dont know. May be I have to design a personlized query in bricks.?

Thank you

This Pro tutorial for Bricks users provides the steps to output posts (of Program CPT) related to the current single post (of Travel CPT) filtered to only those that have a specific taxomomy (program-type) term (long-travel) where the relationship is set up via Meta Box.

In other words, show only long travel programs related to the current travel entry.

Step 1

Install and active Meta Box and Meta Box AIO.

Create travel and program CPTs.

Add program-type taxonomy for the program CPT.

Populate the taxonomy with terms like 'Short Trip', 'Long Travel' as needed.

Populate the CPTs with some sample posts.

Step 2

Add a new Relationship.

Note the auto-generated ID of the relationship. In this case, it'd be travel-program.

Step 3

Edit all the posts of any of the two post types and set up the connected/related posts of the other post type.

Sample travel post:

In the above example, 'ArtVo Tour' program's program type is set to 'Short Trips'.

'Great Ocean Road Drive' program's program type is set to 'Long Travel'.

After implementing the tutorial, only 'Great Ocean Road Drive' will appear as the related program for Melbourne travel post since we are going to limit the related programs to only those that are termed 'Long Travel'.

Step 4

Create a template titled say 'Travel' of type 'Single'.

Edit it with Bricks.

Add a condition to apply the template to all single posts of Travel CPT.

Add a Section showing the post title and content.

Add another Section and inside its Container, a Block.

Enable query loop on the Block and paste:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Filtering posts by a group field’s subfield value with Meta Box when using a custom table in Bricks

Filtering posts by a group field’s subfield value with Meta Box when using a custom table in Bricks

Filtering a query loop to output only those posts with the value of a Select subfield of a Group field set to Yes when using…
Categories:
Tags:
Pro
Related Episodes Grouped by Episode Chapters on Single Podcasts in Bricks when using JetEngine

Related Episodes Grouped by Episode Chapters on Single Podcasts in Bricks when using JetEngine

A user asks: How to Display Related Episodes Grouped by Chapters on a Podcast Page in Bricks? Hi everyone, I have two post types created…
Pro
Meta Box Image Advanced Field Images in Bricks Query Loop

Meta Box Image Advanced Field Images in Bricks Query Loop

Updated on 3 Feb 2025 A user asked: Do you know what the best way to query an image from metabox gallery? I would like…
Categories:
Tags:
Pro
Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

How to register a new dynamic tag for setting excerpt word limits and outputting an ellipsis (...) at the end.
Categories:
Pro
Meta Box Relationship in Bricks using Posts Query Loop

Meta Box Relationship in Bricks using Posts Query Loop

This Pro tutorial is similar to the recent ACF Relationship in Bricks using Posts Query Loop guide but for Meta Box. In the past, we…
Categories:
Pro
Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Creating a custom condition that returns true or false depending on whether today falls within 5 days before any holiday dates selected on a Meta…
Categories:
Tags: