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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro