I created a Custom Field with the Repeater layout to add some input text. I would like to display all the values. I found some code on ACF documentation but I can't understand how it works
<?php
$rows = get_field('repeater_field_name');
if($rows)
{
echo '<ul>';
foreach($rows as $row)
{
echo '<li>sub_field_1 = ' . $row['sub_field_1'] . ', sub_field_2 = ' . $row['sub_field_2'] .', etc</li>';
}
echo '</ul>';
}
?>
http://www.advancedcustomfields.com/resources/repeater/
I don't know how much fields I will create with the Repeater and I would like to loop all the values with foreach. Is that possible?
Thank you in advance
get_field('MY_repeater_field_name');
and my field_name:$row['MY_sub_field_1']
but it doesn't works. It returns me this:sub_field_1 = , sub_field_2 = , etc sub_field_1 = , sub_field_2 = , etc
– Makiarray(2) { [0]=> array(1) { ["testo"]=> string(10) "My Value 1" } [1]=> array(1) { ["testo"]=> string(10) "My Value 2" } }
So can this code help me? – Maki