Recently when the Magazine layouts were introduced in WordPress themes, displaying posts by columns became quite popular. In this recipe, you'll learn how to easily display your posts in two columns.
The following code is simply a WordPress loop containing several PHP instructions to order posts in two distinct columns. It can be used for any WordPress theme.
Open
index.php
and find your current loop. Replace the loop by the following code:<?php $hol = 1; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if ($hol == 1) echo "<div class=\"row\">"; ?> <div class="post hol<?php echo $hol;?>" id="post-<?phpthe_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?phpthe_title(); ?></a></h2> <p><?php the_excerpt(); ?></p> <?php if ($hol == 1) echo "</div>"; ...