Home › Forums › Add-ons › Repeater Field › Changing the integer in a loop › Reply To: Changing the integer in a loop
Hi @chrisfry
Sounds like you need to use a counter variable to dynamicaly echo the row number. You can do this like so:
<?php if(get_field('menu_item')): $i = 0; ?>
<?php while(has_sub_field('menu_item')): $i++; ?>
<div id="test-<?php echo $i; ?>">
</div>
<?php endwhile; ?>
<?php endif; ?>
Note that the variable $i will increment each row, and you can render it with the echo function.
Does that help?
Cheers
E
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.