6th Feb '24
/
2 comments

Filtering ACF Relationship Query by Post Meta in Bricks

This Pro tutorial provides the steps to filter the posts of a post type related to another post type based on the value of a True / False type ACF field in Bricks.

Consider this scenario:

  • Practitioners CPT
    • Practitioners Therapy Relationship field
  • Therapies CPT
    • Associated Practitioners Relationship field
    • Active? True / False field

The requirement is to list all the Practitioners on a Page with their corresponding or related therapies but only those not marked inactive.

Practitioners List:

Therapies List:

Output after implementing the tutorial:

Step 1

Create your CPTs.

Create field groups for each.

Practitioner Fields:

Therapy Fields:

Step 2

Add Practitioner and Therapy CPT entries.

Edit any CPT's entries and select the related items of the other CPT. Since the relationships have been set to be bi-directional, the other post type's Relationship field will automatically get populated.

Edit your therapies and update those that should be inactive using the True / False type custom field.

A therapy marked as inactive:

Another therapy that is NOT marked inactive (default state):

Step 3

Edit the Page where you'd like to show the practitioners' grid with Bricks.

Set it up like this:

Outer query loop:

Set the Posts per page to a large number.

Inner query loop:

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
ACF Font Awesome Field in Bricks

ACF Font Awesome Field in Bricks

We walk through using the Advanced Custom Fields: Font Awesome Field plugin for showing Font Awesome icons.
Categories:
Tags:
Pro
Merging ACF Gallery Images with Featured Image in Bricks

Merging ACF Gallery Images with Featured Image in Bricks

Updated on 12 Mar 2025 In the Bricks Facebook group a user asks: Merging images from different fields into a single gallery Hi, I have…
Categories:
Pro
ACF Relationship: Show all other events related to the artists of the current event

ACF Relationship: Show all other events related to the artists of the current event

How all other events related to the artists of the current event can be output in a Bricks query loop.
Categories:
Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
Pro
Conditional Output based on Date Time Picker Field in Bricks

Conditional Output based on Date Time Picker Field in Bricks

In the past, we showed how elements can be conditionally output based on a post's Date type of ACF field here. This Pro tutorial for…
Categories:
Pro
Sorting ACF Relationship Posts by Date Meta in Bricks

Sorting ACF Relationship Posts by Date Meta in Bricks

Consider the following setup: CPT: Events ACF Fields:Event Date Information (Group)|__Event Date (Date Picker)Pick Sub Events (Relationship) An Event can have 1 or more related…
Pro
Related Services grouped by Service Categories on Single Branch Posts in Bricks

Related Services grouped by Service Categories on Single Branch Posts in Bricks

How to query ACF relationship fields on single CPT templates.
Categories: