Forums

[resolved] How do i reduce this to one loop? (3 posts)

  1. Ahrengot
    Member
    Posted 11 months ago #

    Hello guys,

    I have the following code that i would like to optimize by reducing the 2 loops to a single one.

    Problem is that there's some specific code i only need run once(the nav and section elements). Those need to be outside the loop, so i'm forced to close the nav loop before i can begin the section loop.

    Any help would be greatly appeciated.

    You can see what i have here: http://pastebin.com/VChkx4yR

  2. alchymyth
    The Sweeper
    Posted 11 months ago #

    you can remove the second identical query by using rewind_posts() instead, however, afaik, you will need to keep the two loops.

    http://codex.wordpress.org/Function_Reference/rewind_posts

  3. Ahrengot
    Member
    Posted 11 months ago #

    Wow, what a neat little function. That means I don't even have to do any refactoring of my markup.

    Thanks a lot :)

Reply

You must log in to post.

About this Topic