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

  • Hi Finally figured it out. I realized that mistyped repeater sub name. Anyway since it’s only 6 items, for now this is my solution. Thank you for helping to start!

    <?php
     
     $row_html = array();
     while(have_rows('repeater')) {
      the_row();
      $index = get_row_index();
      $row_html[$index] = get_sub_field('repeatersub');
     }
     
     $count = count($row_html);
     
     if($count==1) {
      echo 'Im 1';
     }
     
     elseif($count==2){
      echo 'Im 2';
      echo $row_html[2];
      echo $row_html[1];
     }
     
     elseif($count==3){
      echo 'Im 3';
      echo $row_html[3];
      echo $row_html[1];
      echo $row_html[2];
     }
     
     elseif($count==4){
      echo 'Im 4';
      echo $row_html[4];
      echo $row_html[1];
      echo $row_html[2];
      echo $row_html[3];
     }
     
     elseif($count==5){
      echo 'Im 5';
      echo $row_html[2];
      echo $row_html[4];
      echo $row_html[3];
      echo $row_html[5];
      echo $row_html[1];
     }
     
     elseif($count==6){
      echo 'Im 6';
      echo $row_html[5];
      echo $row_html[6];
      echo $row_html[3];
      echo $row_html[2];
      echo $row_html[1];
      echo $row_html[4];
     }
     
     else {
      echo 'None';
     }
     
     ?>