Home Forums Add-ons Repeater Field Multiple Repeater fields on single field wont work


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 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>
      <?php endwhile; endif; ?>
  • 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: reset_rows();

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Multiple Repeater fields on single field wont work’ is closed to new replies.