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

Related Tutorials..

Pro
Events grouped by Event Date custom field in Bricks

Events grouped by Event Date custom field in Bricks

This Pro tutorial for Bricks users provides the steps to output posts of an event custom post type dynamically grouped by the value of their…
Categories:
How to create parallax effects using Rellax.js in Bricks

How to create parallax effects using Rellax.js in Bricks

This tutorial provides the JS & PHP codes that can be pasted in order to create smooth parallax effects using the Rellax.js library inside Bricks…
Categories:
Pro
Bricks Slider Images From ACF Flexible Content Sub Field

Bricks Slider Images From ACF Flexible Content Sub Field

Consider the following field group associated with Pages when using ACF Pro: "Page Fields" field group|_"Page Content" Flexible Content field|__"Layout 1" layout|___"Title" Text field|___"Layout 1…
Pro
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.
Pro
Google Maps JavaScript API in Bricks

Google Maps JavaScript API in Bricks

This Pro tutorial provides the steps to show post-specific maps with custom marker content in Bricks using Google's Maps JavaScript API and Advanced Custom Fields.…
Categories: