8th Oct '25
/
0 comments

Filtering ACF Repeater Bricks Query Loop by Sub Field Value

In the BricksLabs Facebook group a user asked:

I'm displaying an ACF repeater on a page using Bricks query loop. I want to filter the rows based on a radio or select field. Is this possible, or should I use CPT in the query loop instead?

The ACF repeater is for a team members section. Each member has a role. My plan is to create 3 separate loops for each role and display the members in each role separately.

I know this is possible with a CPT but it's a requested modification to an already existing setup. Is it still doable with just querying the ACF repeater or should I just create a CPT and migrate the team members data there?

This Pro tutorial shows how ACF Repeater rows output by a Bricks query loop can be filtered using the bricks/query/run PHP filter.

Consider this field group attached to a Page:

and a sample Page with the Repeater field populated like this:

When this Page or a template that applies to this Page is edited with Bricks, a query loop can be enabled on a Block like this:

to show all the team members on the front end:

Now the objective is to say, show only the team members that are in the Engineering department or only in HR.

After implementing the tutorial - output of two different query loops, each filtered to show only the rows from matching department sub field name:

This works with any ACF field type that contains a string value.

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
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.
Adding any Custom WP_Query loop to Bricks’ Query Loop

Adding any Custom WP_Query loop to Bricks’ Query Loop

Sometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…
ACF Checkbox Items with Custom SVG Bullets in Bricks

ACF Checkbox Items with Custom SVG Bullets in Bricks

We walk through outputting list items with SVG icons based on the choice of a ACF Checkbox field.
Categories:
Tags:
How to conditionally load your scripts based on an ACF field

How to conditionally load your scripts based on an ACF field

This tutorial provides the PHP codes that can be pasted in order to enqueue your scripts conditionally based on the value of an ACF field…
Categories: