I want to display my wordpress posts in a category in two divs. So for example:
<ul id="left">
<li class="post">POST 1</li>
<li class="post">POST 3</li>
<li class="post">POST 5</li>
<li class="post">POST 7</li>
</ul>
<ul id="right">
<li class="post">POST 2</li>
<li class="post">POST 4</li>
<li class="post">POST 6</li>
<li class="post">POST 8</li>
</ul>
So want I need to do is tell the query_posts to somehow start spitting out the first 4 posts oddly and then evenly for each div. I don’t want to have two seperate WP_Queries as this is a category.php file and needs to have the default loop. Not quite sure how to do this.
Any help much appreciated.
I have not test this before, this is not the best way but a solution
or the same idea, but another way:
How about preconstructing the two lists: (I can’t recall the WP query syntax, so it’s pseudo-PHP:)
Now list1 contains the first, third, … item and list2 contains the second, fourth, …
You can then print them in the two divs as you wish.
(On a tangent: Does PHP have any succinct way to do what the above code does? Python has the stepped slicing syntax…)
If your goal is to have a two-column list of posts, it would be much easier to just output the posts in one list, and then use CSS to give the visual appearance of two columns using float, for instance: