27th Oct '22
/
4 comments

Accessing ACF Repeater Sub Fields Programmatically in Bricks Query Loop

It is possible to output sub field’s values when a Bricks query loop’s type has been set to a ACF Repeater without writing code. This is built-in.

If you are looking to get/output the sub field’s value via code instead, simply using the_sub_field() or get_sub_field() is not going to work [unless we loop through the entire have_rows()].

Here’s how the sub field values can be output in a Code element:

<?php

// get the current row in the loop
$acf_row = \Bricks\Query::get_loop_object();
// print_r( $acf_row );

echo $acf_row['details']; 

?>

Given

and

and

for example, sample output of

print_r( $acf_row );

is:

Array ( [name] => Head Massage [details] => Dolor tempor irure irure aute pariatur. Aliqua mollit cillum ad elit. Elit aliquip fugiat reprehenderit incididunt deserunt. Aliqua qui magna amet proident fugiat ut exercitation exercitation enim sunt velit incididunt pariatur. )

Source: https://forum.bricksbuilder.io/t/acf-repeater-get-sub-field-not-working/7281

Get access to all 610 Bricks code tutorials with BricksLabs Pro

4 comments

Leave a Reply to John McBade (Cancel Reply)

 

Related Tutorials..

Pro
CPT Submenu Items in ACF Pro Options Admin Menu

CPT Submenu Items in ACF Pro Options Admin Menu

This Pro tutorial provides the steps to add links to admin pages under an Options page created with ACF Pro. All code mentioned in this…
How to create filters with IsotopeJS in Bricks (Part 3): apply multiple filters

How to create filters with IsotopeJS in Bricks (Part 3): apply multiple filters

This tutorial will review how to apply multiple filters to an isotope container using the IsotopeJS library‘s features in Bricks.
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

This tutorial provides the PHP & JS codes that can be pasted in order to create a flying effect on map markers each time your…
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
ACF Post Object Query Loop inside a Posts Query Loop in Bricks

ACF Post Object Query Loop inside a Posts Query Loop in Bricks

How to loop through a CPT and within each post, output a list of related posts.
Categories:
Pro
How to Update Custom Fields with Default Values For Existing Posts when using ACF

How to Update Custom Fields with Default Values For Existing Posts when using ACF

Let's take a scenario where there are 10 Pages in a WordPress site. You proceed to create a Text-type of custom field called, say, "Custom…
Categories:
Tags: