Grouping posts in pairs
-
Is there anyway to group posts in pairs?
I have a category with 5 posts like this:<div class=”col6″>
<p>post_1</>
</div>
<div class=”col6″>
<p>post_2</>
</div>
<div class=”col6″>
<p>post_3</>
</div>
<div class=”col6″>
<p>post_4</>
</div>
<div class=”col6″>
<p>post_5</>
</div>And I need to group them in pairs as follow:
<div class=”row”>
<div class=”col6″>
<p>post_1</>
</div>
<div class=”col6″>
<p>post_2</>
</div>
</div>
<div class=”row”>
<div class=”col6″>
<p>post_3</>
</div>
<div class=”col6″>
<p>post_4</>
</div>
</div>
<div class=”row”>
<div class=”col6″>
<p>post_5</>
</div>
</div>I have tried using a var that counts the post and if is odd opens <div class=”row”> and if is even closes the tag…. the problem comes with the last post which is even so the tag doesn’t close…
Any help would be great!!
Thanks!!
The topic ‘Grouping posts in pairs’ is closed to new replies.