I have been pretty impressed with the recent redesign at WebDesignerDepot and I am curious about the mechanics of their homepage. I like how they have featured post sections that break up the monotony of the page, but I haven’t figured out how to incorporate something similar in my own designs. I’m guessing that they are using multiple loops and it seems like it’s something like [main loop chronological] — > [custom loop] —> [main loop continues chronologically].
How would I break off into a custom loop and then continue where I left off in the main loop?
You can use
current_post
within the loop to track where you are and split the loop into multiple parts:You can also use
$wp_query->rewind_posts();
to run the same loop again, or setcurrent_post
directly to start a loop at a specific post:Just remember that
current_post
is zero-indexed, it starts at zero, not 1.