Home › Forums › Add-ons › Repeater Field › Repeater Field Bug: Looping First Field
Hello there, hope everyone is well
I’ll get straight to the point on this one. I’ve had a look all over the internet for a solution but no results or posts even closely relating.
The problem is that i’ve created a repeater field to contain two simple fields, one is the title for the content ‘tip_title’(text field) and the other is the content associated ‘tip_content‘(text area) as shown below:-
<div id="archiveTipBox"> <?php if(get_field('archive_tips')): ?> <?php while(has_sub_field('archive_tips')): ?> <div id="archiveTipsBoxContent"> <div class="tipTitle"><?php echo the_sub_field('tip_title');?></div> <div class="tipContent"> <?php echo the_sub_field('tip_content');?> </div> </div> <?php endwhile; ?> <?php endif; ?> </div>
It has no problem repeating tip_title for each entry but for tip_content it just shows the first one in every single entry which makes no sense
Any help on this would be greatly appreciated as i’m completely lost
I’ve also attached these images just to show you in more detail
Perhaps this might help you.
<div id="archiveTipBox"> <?php if( have_rows('archive_tips') ): while ( have_rows('archive_tips') ) : the_row(); ?> <div id="archiveTipsBoxContent"> <div class="tipTitle"><?php the_sub_field('tip_title'); ?></div> <div class="tipContent"> <?php the_sub_field('tip_content'); ?> </div> </div> <?php endwhile; ?> <?php else : endif; ?> </div>
Hi The code provided by @gwundrig should work perfectly,
In your code you are missing the_row();
which enables the repeater to loop through all the rows in the repeater.
You must be logged in to reply to this topic.
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.