I need to create a loop that can logically be described as the following for a carousel:
Requirements:
- 3 Loops
- 2 Posts Per Loop
- No Duplicates
- Order by Post Date
Visual:
< Start Loop #1 >
< Post #1 >
< Post #2 >
< End Loop #1 >
< Start Loop #2 >
< Post #3 >
< Post #4 >
< End Loop #2 >
< Start Loop #3 >
< Post #5 >
< Post #6 >
< End Loop #3 >
Ideally, I would like a solution that could carry on infinite loops this way with no duplicates. I looked in the WP codex, but I could not find a specific solution that fit with my code shown here: http://pastebin.com/LitYb0wh
How can I make the loop to work with this type of structure?
<ul>
<li>
<div>Post 1</div>
<div>Post 2</div>
</li>
<li>
<div>Post 3</div>
<div>Post 4</div>
</li>
<li>
<div>Post 5</div>
<div>Post 6</div>
</li>
</ul>
i use this code in my portfolio http://pocketapps.co/
To precisely match your three
<ul>
pattern you can do this:However, the following it smaller, neater, and should create any number of
<ul>
s depending on the size of the query, which I assume is what you mean when you say “infinite loops this way”.An option using a single
<ul>
The
$args
I used to test is…… but this should work with any that your provide.
It does assume that you don’t want to query for a distinct set of posts for each Loop.
Obviously, I did not work this into your existing code but the pattern should be easy to apply.