Support

Account

Home Forums General Issues Check repeater rows with value before loop Reply To: Check repeater rows with value before loop

  • When I need to do this type of thing I use output buffering.

    
    if (have_rows('repeater')) {
      ob_start();
      $display_row_count = 0;
      while (have_rows('repeater')) {
        the_row();
        if (get_sub_field('true_false')) {
          $display_row_count++;
          // other code
        }
      } // end while have rows
      $content = ob_get_clean();
      if ($display_row_count >= 2) {
        echo $content;
      }
    } // end if have rows