An easy way to make two columns in WordPress

Searching around on the internet I found a few solutions to the problem I faced, but I felt they were more complicated then they needed to be. The problem was I had a list of posts and i wanted to display them in two columns in alphabetical order. Here was my solution.

First thing i did was I made variable called $rowcount outside of the wordpress loop, like this:

$rowcount = 0;

Secondly, I add a div for my left column outside of the loop.

<div style="float:left; width:40%;">

Thirdly, inside of the loop I incremented the $rowcount variable like this:

$rowcount++; // incrememnt rowcount var

Fourth, a simple if statement looking for rowcount 17 and close the initial div and open a new div.

if ($rowcount == 17 ) {
  echo "</div><div style='float:left; width:40%;'>";
}

Fifth, I output the content i wanted from the posts.

I closed up the loop.

I close the div outside of the loop.

That’s it. Fin.

In

Leave a Reply

Your email address will not be published. Required fields are marked *