If you’re rolling your own WordPress loop(s), then this trick comes in handy when you build a “grid loop”. A grid loop has post teasers side-by-side in a column.
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div id="post-<?php the_ID(); ?>" <?php $even_odd = (++$j % 2 == 0) ? 'even-post' : 'odd-post'; post_class( $even_odd ); ?>
<p><?php the_excerpt(); ?><>
</div>
<?php endwhile; endif; ?>
Then in your CSS:
.odd-post {
clear: both;
}












Recent Comments