Support

Account

Home Forums ACF PRO Multiple Repeater fields on single page wont work Reply To: Multiple Repeater fields on single page wont work

  • Okay so i stumbled upon this solution by accident but it works for me so maybe it works for you as well.

    I use the code of @jorgecastellonjr for my explanation.
    This is his original 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>

    The only thing you have to do is to add the following code before your if-statement for the second repeater:
    <?php have_rows( 'bottom_item' ) ): ?>

    And the code will look like this:

    <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 ( have_rows( 'bottom_item' ) ): ?>
       <?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>

    I hope this works for you guys as well!