19th Jul '24
/
0 comments

Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

A couple of members asked:

I have a cpt called "Markets" aand a cpt "tools". Tools have a taxonomy "tools group". How can i create a relation between Market (cpt) and tool group (taxonomy). My goal is to display related market inside the tool group (taxonomy) archive. Thanks

Hi, I have a CPT=“Product” with a taxonomy=”Product-group” and a CPT=”Team member”. Is it possible to link Team member and product-group with a bi-directional relation using ACF? And then ouput the related product group inside team member single template? It would be great if you're able to help me with this! Many thanks in advance!

This Pro tutorial walks through the process of setting up a bidirectional relationship between posts of a CPT and a custom taxonomy of another CPT and outputting the items of related object(s) on the single CPT pages and term archive pages in Bricks using ACF.

Scenario covered in this tutorial: Team Member <-> Product Category.

Product Category is a taxonomy for another CPT (Product).

Sample Team Member posts:

After implementing the tutorial, 'Employee A' post on the front end:

'Employee B' post on the front end:

'Decor' product category archive in the backend:

On the front end:

'Music' product category archive in the backend:

On the front end:

We shall also ensure that the Sections get output only if there is at least one related item (CPT post or taxonomy term).

Step 1

Install and activate ACF.

Create your CPT.

Ex.:

Create the other CPT and an associated taxonomy. In our dev site, we used product CPT and product_cat taxonomy that come with WooCommerce.

Step 2

Create a field group for your main CPT (team-member in this example).

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 612 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Custom Function for ACF Link Field

Custom Function for ACF Link Field

How to output the label of an ACF link field through Dynamic Data.
Categories:
Tags:
How to create a dynamic infinite logo slider with ACF and Bricks

How to create a dynamic infinite logo slider with ACF and Bricks

This tutorial provides the builder settings, PHP & CSS codes that can be pasted in order to create an infinite logo slider in pure CSS…
ACF Repeater Sub Field Values as Tabs in Bricks

ACF Repeater Sub Field Values as Tabs in Bricks

Bricks' query loop supports ACF Repeaters and Meta Box Groups out of the box besides posts, users and terms. This tutorial shows how we can…
Categories:
Tags:
Pro
Sub Field Value from the Last ACF Repeater Row in Bricks

Sub Field Value from the Last ACF Repeater Row in Bricks

Getting the value of a specific sub field of an ACF Pro‘s Repeater field and output in the query loop.
Categories:
Tags:
Pro
ACF Repeater Row Count Condition in Bricks

ACF Repeater Row Count Condition in Bricks

This Pro tutorial provides the steps to output elements on single posts (of any post type) in Bricks only if a specific ACF Repeater-type of…
Categories: