16th May '25
/
0 comments

Filtering ACF Settings Page Repeater For Current Single Posts in Bricks

In the Bricks Facebook group a user asked:

Hey! Any idea how to filter ACF Repeater Field with relationship Field?

The idea it's the next one:

1. One CPT Called "Courses"

2. Global Options with a TimeTable with repeater Field, on this timetable, with some fields like "Day", "Price", and "Course (Relationship field)"

3. Subfield with "Relationship" to link with the Course

4. Show on the courses single post only the Rows that are linked.

The idea it's manage from one place the table and show dinamically the fields that are linked on the specific course to avoid go course by course changing the content.

Thanks in advance 🙂

Consider this scenario:

CPT: course

Options page: Site Settings

Field group for Site Settings:

  • time_table (Repeater)
    • day (Date Picker)
    • price (Number)
    • course (Relationship)

Repeater Field being populated on the options page:

Requirement 1: output the courses in a tabular format on a /courses listing page/archive

After implementing the tutorial:

Requirement 2: output only the rows that have the current single course being viewed

After implementing the tutorial, Course 1 post page:

We chose to not include the Courses column because the user expects to see only those that are relevant to the current course.

Course 2 post page:

Course 3 post page:

This Pro tutorial provides the steps to set up a dynamic CPT ACF Repeater data table (with optional search, pagination, column sorting etc.) that loops through the rows and outputs the data populated on the settings page in columns on a page plus, filter the data table to only include the rows that contain the current single course via bricks/query/result filter when viewing single courses.

What is covered in this tutorial is also a good way to implement events in WordPress.

Step 1

Install and activate ACF Pro.

Create the Courses (or Events) CPT.

Add a Settings page.

Add a field group on the above settings page having a Repeater with a Relationship sub field.

Visit the settings page and add rows.

Step 2

Install and activate BricksExtras. We shall use its Dynamic Table element.

Edit the page (a static Page or the CPT archive template) in which you'd like to show all the courses as a data table with Bricks.

Add a Section and inside its Container, Dynamic Table element.

Enable query loop and for the query type, select your ACF Repeater.

Add columns.

Step 3

Create a single template for your CPT and edit it with Bricks.

Copy the Section from the above page/template and paste.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

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
Setting a Bricks template for Parent pages

Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that…
Pro
Programmatically populating ACF field values in WordPress

Programmatically populating ACF field values in WordPress

An example of how to set the values of a Select-type field with the names and labels of all public post types.
Categories:
How to hide/remove the Block Element from the Bricks Builder

How to hide/remove the Block Element from the Bricks Builder

Don't like the new Block element in Bricks? Just copy/paste the following code into your child theme's functions.php. By the way, It's a terrible idea…
Categories:
Tags:
Pro
Prefiltering Bricks Terms Query Loop

Prefiltering Bricks Terms Query Loop

Let's say there's a Events CPT with a 'Event Year' custom taxonomy. Sample event year names could be: 2021, 2022, 2024, 2025, 2028 etc. We…
Pro
ACF Options Fields in Bricks

ACF Options Fields in Bricks

This Pro tutorial walks you through outputting the values of custom fields attached to an ACF Pro's Options page in Bricks builder. We shall register…
Categories: