Support

Account

Home Forums Add-ons Flexible Content Field Check if end of loop or next row layout's name Reply To: Check if end of loop or next row layout's name

  • 
    $layouts = get_field('field_name', false, false);
    $count = 0;
    while (have_rows('flex_field')) {
      the_row();
      
      // normal code for displaying your layout here
    
      if ($count == count($layouts)) {
        // end of layouts reached
        // do end of loop code
      }
    
      if (isset($layouts[$count+1])) {
        if ($layout[$count+1] == 'Layout B') {
          // next layout is layout be
          // do that code
        }
      }
    
      // increment count
      $count++;
    
    } // end while have rows