Home › Forums › Add-ons › Repeater Field › List All Sub Fields in a Repeater or Flex Field › Reply To: List All Sub Fields in a Repeater or Flex Field
What you’re doing is not the same as what @chriscarvache is looking for tho.
And fetching the repeater field into an array does work, I’ve done it many many times 🙂
However I might have to explain it with a bit more code:
<?php
$repeater = get_field('repeaterfieldname');
//make sure atleast 1 row exists
if( $repeater ){
/* $repeater contains something like this, where each inner array represents a single row.
array(
[0] => array(
'subfield1' => 'value',
'subfield2' => 'value'
),
[1] => array(
'subfield1' => 'value',
'subfield2' => 'value'
),
[2] => array(
'subfield1' => 'value',
'subfield2' => 'value'
)
)
*/
foreach( $repeater as $row ){
//$row now contains all the subfields in this row of the repeater..
print_r($row);
}
}
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.