Home › Forums › Add-ons › Repeater Field › Unable to get the repeater field working (Never passes has_sub_field while loop) › Reply To: Unable to get the repeater field working (Never passes has_sub_field while loop)
Hi @rpk
I think the issue is that you are using the wrong field name for the has_sub_field loop.
This function requires the field name to be the ‘repeater field’ name, not one of the sub fields.
Your code:
<?php if(get_field( 'pro_repeatertest' ) ): ?>
<?php echo 'We are in the if loop'; ?>
<ul>
<?php while( has_sub_field( 'pro_food' ) ): ?>
Should be changed to:
<?php if(get_field( 'pro_repeatertest' ) ): ?>
<?php echo 'We are in the if loop'; ?>
<ul>
<?php while( has_sub_field( 'pro_repeatertest' ) ): ?>
Thanks
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.