title: Query related posts, Wrap in Row every 3 posts
body: <p>I'm trying to query some related posts and wrap them in a row div every 3 posts. I've checked all the questions regarding this but still my query renders a mess.
  This is what I have so far:</p>
  
  <pre><code>&lt;?php
  $related = get_posts( array(
  'category__in' =&gt; wp_get_post_categories($post-&gt;ID),
  'numberposts' =&gt; 6,
  'post__not_in' =&gt; array($post-&gt;ID) ) );
  $counter=0;
  if( $related ) foreach( $related as $post ) {
  setup_postdata($post); $counter++;
   ?&gt;
  
  &lt;div class="row"&gt;
      &lt;article class="third-width"&gt;
          &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title(); ?&gt;" class="third-link"&gt;           
              &lt;?php  the_post_thumbnail('post-parrilla'); ?&gt;
          &lt;/a&gt;
  &lt;?php exclude_post_categories("8"); ?&gt;
  &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title(); ?&gt;" class="third-link"&gt;           
          &lt;div class="post-title"&gt;
          &lt;span&gt;&lt;?php the_title(); ?&gt;&lt;/span&gt;
          &lt;/div&gt;
      &lt;/a&gt;
      &lt;/article&gt;
  
  &lt;?php if ($counter%3==0):?&gt;
      &lt;/div&gt;&lt;div class="row"&gt; 
  &lt;?php endif;?&gt;
  &lt;?php } wp_reset_postdata(); ?&gt;
  </code></pre>
  
  <p>Thank you in advance</p>