title: How to count the total number of rows in a ACF repeater output
body: <p><strong>Question:</strong> How do you simply count the rows in the output of an ACF repeater field?</p>
  
  <p><strong>Goal:</strong> to make the output look different with a css class when there's only one row, vs. more than one row.</p>
  
  <p><strong>My code:</strong> </p>
  
  <pre><code>if( have_rows('testimonials')) {
      $counter = 0;
      $numtestimonials = '';
  
      //loop thru the rows
      while ( have_rows('testimonials') ){
          the_row();
          $counter++;
              if ($counter &lt; 2) {                         
                  $numtestimonials = 'onlyone';               
              }
          echo '&lt;div class="testimonial ' . $numtestimonials . '"&gt;';
             // bunch of output here
          echo '&lt;/div&gt;';                          
      }
  }
  </code></pre>
  
  <p>Obviously, The way I do it here will not work as the count is &lt; 2 the first time thru the row, so it returns true even if more rows are counted after.</p>
  
  <p>Thank you!</p>