17th Mar '23
/
8 comments

Conditional Rendering of ACF Repeater Rows Based on True / False Sub Field in Bricks

This Pro tutorial provides the steps to modify a ACF Repeater query loop to only output the rows for which a True / False type of sub field's value is true.

ACF field group:

Fields populated for a Page

Front end before implementing this tutorial:

Front end after implementing this tutorial:

Step 1

Create a field group using ACF Pro having a Repeater-type of field with your desired sub fields.

For the sub field of the type True / False, ensure that "Default Value" is ticked. This will set the default value of this field to true (Yes).

You may want to turn "Stylized UI" setting under the Presentation tab on.

Here's the JSON file of the field group export from our test site. Mirror.

Step 2

Edit your template/Page with Bricks.

Add a Section and inside its Container, a Block.

Enable query loop on the Block.

Set the query type to your ACF Repeater.

Add the Heading/Basic Text elements as needed and set their text to show your text-type sub fields.

Ex.:

Step 3

Next we need to modify the query results of the specified query loop to only include the rows where the active sub field is true.

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
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
ACF Image Data in Bricks

ACF Image Data in Bricks

Displaying Alt text, Caption, Title and URL of an ACF image field for posts in a query loop.
Categories:
Tags:
Color Custom Field as Section Background Color on Category/Term Archives in Bricks

Color Custom Field as Section Background Color on Category/Term Archives in Bricks

How to use a color from a taxonomy term custom field for as the hero section background color on archive pages.
Categories:
Tags:
Pro
Conditional single post Bricks template based on internal referrer URL

Conditional single post Bricks template based on internal referrer URL

How to automatically select a single post template depending on the page from which the post is accessed.
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:
Weekday Condition in Bricks

Weekday Condition in Bricks

As of Bricks 1.7, the built-in "Weekday" condition does not work correctly. This is most likely due to it not taking the site's timezone (set…
Categories:
Pro
Conditionally outputting an element in a Query Loop based on date-type custom field

Conditionally outputting an element in a Query Loop based on date-type custom field

This Pro tutorial shows how to output an element in a Bricks' query loop only if the value of a date-type of custom field for…
Categories: