I am focusing on a wordpress theme, and I've got a rather unique structure that I have to output the outcomes in the Loop into. The output could be simplified towards the following:

<div class="row">
  <div class="entry-1">
    /* details from first iteration of The Loop */
  </div>
  <div class="entry-2">
    /* details from second iteration of The Loop */
  </div>
</div>
<div class="row">
  <div class="entry-3">
    /* details from third iteration of The Loop */
  </div>
  <div class="entry-4">
    /* details from fourth iteration of The Loop */
  </div>
</div>

So essentially, I want the very first two iterations from the Loop to output their particulars inside a master DIV getting the course title of "row". The following two iterations have to do exactly the same, inside a new DIV getting exactly the same aforementioned class title. This could carry on until have_posts() is fake, accomodating the potential of getting just one remaining publish, which may find itself alone inside a master DIV getting, again, the course title of "row".

I can not appear to think about the easiest method to make this happen. Any direction could be greatly appreciated:

while ( have_posts() ) : the_post();
  /* My mind is blank */
endwhile;
<?php

$i = 1; while ( have_posts() ) : the_post();

$even = ($i % 2);

if (!$even)
   echo '<div class="row">';
?>

<div class="entry-<?php echo $i; ?>">
    My Details
</div>

<?php

if ($even || $i == $wp_query->post_count)
   echo '</div>';

$i++; endwhile;
?>