Support

Account

Home Forums Add-ons Repeater Field How to get the second and third row separetely from repeater Reply To: How to get the second and third row separetely from repeater

  • <?php
    $count = 0;
    $your_repeater = get_field('your_repeater');
    if($your_repeater){
       while( have_rows('your_repeater') ): the_row();
       $count++;
       $my_field = get_sub_field('my_field');
       if ($count == 1) {
          echo '<div class="image1">'.$my_field.'</div>';
       }
       if ($count == 2) {
          echo '<div class="image2">'.$my_field.'</div>';
       }
       if ($count == 3) {
          echo '<div class="image3">'.$my_field.'</div>';
       }
       if ($count == 4) {
          echo '<div class="image4">'.$my_field.'</div>';
       }
       if ($count == 5) {
          echo '<div class="image5">'.$my_field.'</div>';
       }
    endwhile;  
    }
    ?>

    if you need to echo img at different places use a variable instead of echo first. and echo that variable later.

    $image1 = '<div class="image1">'.$my_field.'</div>';
    ...
    echo $image1;

    or you can try to use:

    get_field('repeatername_0_fieldname'); //for first row
    get_field('repeatername_1_fieldname'); //for second row
    ...