Support

Account

Home Forums Add-ons Flexible Content Field How to out put last row only ; While~endwhile Reply To: How to out put last row only ; While~endwhile

  • The only way to do this is to know how many rows you have before you begin and then check the row index in the loop

    
    $rows = count(get_field('visits_range'));
    while (have_rows('visits_range')) {
       the_row();
       $index = get_row_index();
       if ($index + 1 == $rows) {
         // this is the last row
       }
    }