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
4 comments
Simon Pheasey
Thanks for this. Can you tell me how you do this with the ACF Font-Awesome Field plugin installed? i.e. to out put the font awesome icon programtically?
I have tried the above, using the row name of 'icon' (which is an ACF Font Awesome field). but it returns as NULL.
Thanks
Sridhar Katakam
See https://forum.bricksbuilder.io/t/tutorial-on-how-to-use-font-awesome-icons-with-acf-fields/14797/12.
I'll write a tutorial on the same for the Pro members soon.
Sridhar Katakam
Done.
https://brickslabs.com/acf-font-awesome-field-in-bricks/
John McBade
Thank you Sridhar.
I was able to do this in an Archive but I wanted to do it in a Single Template. Between what I learned already and then seeing your post, I thankfully got it sorted.