Support

Account

Home Forums Add-ons Repeater Field Change class of element depending on amount of Repeater Field items Reply To: Change class of element depending on amount of Repeater Field items

  • 
    $row_count = count(get_field('repeater_field_name'));
    $size = 0;
    if ($row_count) {
      $size = (int)12/$row_count;
    }
    if ($size < 2) {
      //force minimum of col-lg-2
      $size = 2;
    }
    $class = 'col-lg-'.$size;
    
    // your repeater loop here