Hello there!

To put posts into two side-by-side columns in WordPress, you’ll need to edit two theme files:

index.php and style.css

I have edited the default theme, so adjust this to suit your own theme.

The basic idea is to add a special “switch” in the code so WordPress knows if you’re looking at a post which will appear in the first or second column.

In index.php I added code in four places:

Before the WordPress loop starts:

<?php $col = 1; ?>

I.e. we set up the switch to start off in the first column.

Just after the WordPress loop starts:

<?php if ($col == 1) echo "<div class="row">"; ?>

Start a new row if we’re in the left hand column.

Inside the WordPress loop:

Add in the switch:

<div class="post col<?php echo $col;?>" id="post-<?php the_ID(); ?>">

I.e. I added in col<?php echo $col;?> to the post’s class. We’ll use CSS code to decide how to display posts in each column.

Just before the end of the WordPress loop:

Change the switch and the row:

<?php if ($col == 1) echo "</div>"; (($col==1) ? $col=2 : $col=1); endwhile; ?>

The WordPress loop ends with endwhile.

Just before this, I do two things: finish the row and I make $col switch between the first or second column. If you haven’t seen code like this before, this is what it’s doing:

Are we in the first column?
Yes: Move to the second column.
No: Move to the first column.

In style.css I added three lines of code at the very bottom:

.row { clear: both; }
.col1 { width: 200px; float: left; padding: 0 10px; }
.col2 { width: 200px; float: right; padding: 0 10px; }

If you’re using a different theme, you may need to adjust the column widths and the amount of padding.

Using a row div forces the two posts to always line up with each other, even if the excerpts are different lengths.

All sorted now? Hooray!

Wait, wait…before you go…

Are you interested in hearing more about my upcoming course on finding your ideal WordPress theme? It’s a jungle out there and so many people come to me needing helping choosing a theme. I’m going to break it down step-by-step and reveal all the things you need to consider, and practical strategies you need to use.

If you don’t want to feel overwhelmed searching for your ideal WordPress theme from 10,000+ choices, then this course is the ideal next step.

  • Have you been Googling “Best WordPress themes”?
  • Do you ask friends and colleagues for premium themes they recommend?
  • Do you look at what your favorite websites are using and try to find out if the theme is available for purchasing?
  • How do you stop worrying about that nagging feeling: if you just searched a little longer, you’d find the perfect theme?
  • How do you know if you’re buying a “lemon” which will cause you no end of troubles?
  • Did you think that it would be easy to find a theme and are now feeling frustrated and exhausted searching?

With a robust framework to guide you through that crazy jungle out there you would:

  • Be fully aware of the hidden dangers and common theme traps which can occur straight away or long into the future.
  • Save valuable money, time and stress.
  • Know what you need to grow your business.

Fill in the form below to learn more!