I want 3 post with one loop iteration, so I'm using the_post() to achieve this: (html removed)
<?php while ( have_posts() ) : the_post();
the_title();
the_post();
the_title();
the_post();
the_title();
endwhile; ?>
The problem starts, if number of posts is not divisible by 3. For example, if I have 5 posts, than this loop will still try to display 6 of them, generating empty html. How can I work it out? Or maybe I'm trying to achieve this functionality the wrong way?
@edit: Here is HTML I wanna output to clarify my question:
<div class="row">
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
</div>
<div class="row">
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
<div class="span3">
<h2>Title</h2>
<p>Content</p>
</div>
</div>
So I want to surround every 3 posts with .row.

the_post()template tag doesn't actually output the post; rather, it merely sets up the$postglobal, and all of the template tags that rely on the$postglobal (such asthe_title()). So, it should only ever be called once inside the Loop. – Chip Bennett Aug 25 '12 at 16:25if ($counter % 3 == 0) do stuffsort of thing. – Otto Aug 25 '12 at 16:48