Home › Forums › Add-ons › Repeater Field › Multiple Repeater fields on single field wont work
I’m having an issue trying to display 2 repeater fields in the same custom field. Both repeater fields work on their own but when I try to have them both work at the same time only the first one works. Here is my code.
<div class="top__wrap"> <?php if ( have_rows( 'top_item' ) ): while( have_rows('top_item') ): the_row(); $value = get_sub_field( 'value' ); ?> <div class="top__item"><?php echo $value ?></div> <?php endwhile; endif;?> </div> <div class="bottom__wrap"> <?php if ( have_rows( 'bottom_item' ) ): $symbol = get_sub_field( 'symbol' ); ?> <div class="bottom__wrapper"> <div class="bottom__item"><?php echo $symbol ?></div> </div> <?php endwhile; endif; ?> </div>
your second section of code is missing
while( have_rows( ‘bottom_item’ ) ): the_row();
Oh sorry, I must have deleted it. My actual code has both “while” on each repeater. I had to make some changes because it’s for a confidential project. But the concept is the same.
Looking at that code, if both repeaters are associated with the same post and that is the post that’s being displayed, and that code in inside “The Loop” then there is no reason that it shouldn’t work.
Okay, so I was running a lot of tests. I realize as soon as I input data into both repeaters, only the first repeater displays. When I delete the data from one of the repeaters then the other one displays. I feel that when I input data into the repeater fields, one is overriding the other in the database.
Is there a repeater reset code or something?
Nevermind I found out what that code was. You answered it in a different question that I found on here. Thanks! Here is the code:
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.