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
Foreach version:
While version:
I would fix it like this: