Support

Account

Home Forums Add-ons Repeater Field ACF Repeater max 6 items display inside table Reply To: ACF Repeater max 6 items display inside table

  • Your if/else should look something like this

    
    if (count($row_html) <= 2) {
      echo 'test 2 items';
    } elseif (count($row_html) <= 3) {
      echo 'test 3 items';
    } else {
      echo 'test';
    }
    

    you could make that simpler to type and read by doing

    
    $count = count($row_html);
    if ($count <= 2) {
      echo 'test 2 items';
    } elseif ($count <= 3) {
      echo 'test 3 items';
    } else {
      echo 'test';
    }
    

    you can simplify it more by using a switch statement which is easier to read when you have a lot of conditions than an if/elseif statement

    
    switch (count($row_html) {
      case 1:
        echo '1 block';
        break;
      case 2:
        echo '2 blocks';
        break;
      case 3:
        echo '3 blocks';
        break;
      case 4:
        echo '4 blocks';
        break;
      case 5:
        echo '5 blocks';
        break;
      case 6:
        echo '6 blocks';
        break;
    }