title: Define Grid Based on Multiple Item Counts
body: <p>Looking to solve a problem I'm having dynamically defining classes using WordPress Advanced Custom Fields' Repeater field. I've done some digging but haven't been able to find a resource with the specificity that I'm looking for.</p>
  
  <p>I'm displaying a series of portfolio images, and depending on how many there are I would like to give certain photos specific class names within the Foundation grid. Essentially I'm looking to do the following:</p>
  
  <ul>
  <li>For items 1-4: Apply a class of large-6</li>
  <li>For items 5+: Apply a class of large-4</li>
  <li>If only 1 item: Apply a class of large-8</li>
  </ul>
  
  <p>I've been able to get the first two examples to work, but I'm having trouble defining a third set of parameters. I've tried a number of different routes but I'm not sure what's best at this point. See below for a mockup of what I am looking to accomplish, as well as my code example.</p>
  
  <p>Appreciate any advice!</p>
  
  <p><a href="https://i.stack.imgur.com/3Hw6D.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Hw6D.jpg" alt="Mockup"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;div class="row portfolio-examples"&gt;
  
   &lt;?php
          if( have_rows('portfolio_examples') ): 
           while ( have_rows('portfolio_examples') ) : the_row();
      $count = 0;
      $work = get_sub_field('portfolio_work');
      ?&gt;
                      
    &lt;?php if ($count != 0 || $count &lt; 4) :?&gt;
          
          &lt;div class="large-6 medium-6 columns end"&gt;
              &lt;?php if( $work ): ?&gt;
                  &lt;img src="&lt;?php echo $work['url']; ?&gt;" alt="&lt;?php echo $work['alt'] ?&gt;" /&gt;
              &lt;?php endif; ?&gt;
          &lt;/div&gt;
    
     &lt;?php else: ?&gt;
          
   &lt;div class="large-8 medium-8 large-centered medium-centered columns"&gt;
              &lt;?php if( $work ): ?&gt;
                  &lt;img src="&lt;?php echo $work['url']; ?&gt;" alt="&lt;?php echo $work['alt'] ?&gt;" /&gt;
              &lt;?php endif; ?&gt;
              &lt;/div&gt;
          
      &lt;?php endif; ?&gt;
      
      &lt;?php 
          $counter++; 
          endwhile;
          endif; 
      ?&gt;
      
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>