title: Unclosed div when wrapping every 2 divs in a loop
body: <p>I have the following set up below.  I'm trying to wrap ever 2 divs in a "row".</p>
  
  <p>When its an even number it works great, but when there's an odd number, I end with an open div and get html errors.  Any ideas on how to better make sure there is a closing div would be appreciated </p>
  
  <pre><code>&lt;?php
  
              $args = array(            
                'post_type' =&gt; 'portfolio-project',
                'posts_per_page' =&gt; -1, 
                'orderby' =&gt; 'menu_order',
                'order' =&gt; 'ASC'
              );
  
              $query = query_posts($args);
  
          ?&gt;
  
          &lt;?php $i=1; ?&gt;
  
          &lt;?php while (have_posts()) : the_post(); ?&gt;
              &lt;?php if($i==1 || $i%2==1) echo '&lt;div class="row"&gt;' ;?&gt;
  
              &lt;div class="col-sm-6"&gt;
                  &lt;?php the_title();?&gt;
              &lt;/div&gt;
  
              &lt;?php if($i%2==0) echo '&lt;/div&gt;' ; ?&gt;
  
          &lt;?php $i++; endwhile; wp_reset_query();?&gt;
  </code></pre>