php - Output three columns and row in loop
75
I am trying to output a loop with three columns surrounded by a row, like this:
<div >
<div #">Title</a></div>
<div #">Title</a></div>
<div #">Title</a></div>
</div>
<div >
<div #">Title</a></div>
<div #">Title</a></div>
<div #">Title</a></div>
</div>
<div >
<div #">Title</a></div>
<div #">Title</a></div>
<div #">Title</a></div>
</div>
Here's what I've come up with. This works for the first and second row, but the third row ends up inside the second row. Any ideas what I'm doing wrong?
<?php
$i = 0;
while ($myposts->have_posts()) : $myposts->the_post(); ?>
<?php if( $count%3 == 0 ) { echo '<div >'; }; $count++; ?>
<div ><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php if( $count%3 == 3 ) { echo '</div>'; }; ?>
<?php endwhile; ?>
Answer
Solution:
What about this: You can play around a bit with first mod number and last one. And make sure you always get 3 titles from $myposts->post()
Answer
Solution:
If I got you, you wanna a div class row every three records or something like that. How I don't know the format of input data I put these example as reference:
Whatever, your problem lay on conditions...