Pre loop_start action.

  1. Clifton Griffin


    loop_start is the most obvious entry point for adding content above The_Loop. Unfortunately, as this portion of the code is in the loop, this prevents me from actually using another loop. (Believe me, I tried.)

    As it is fairly common to use multiple loops (wordpress even has a guide!) this seems like an obvious opportunity for improvement.

    We simply need another action (pre_loop?) or something along those lines.

    Any ideas? Is there something I'm not understanding?


    Posted: 9 years ago #
  2. Binh

    Any example? I don't quite understand what you mean.

    WordPress has wp_query function to let you make multiple loop.

    So ... is that what you want?

    Posted: 9 years ago #
  3. Clifton Griffin


    loop_start is triggered by the_post()...

    function the_post() {
    global $post;
    $this->in_the_loop = true;
    $post = $this->next_post();
    if ( $this->current_post == 0 ) // loop has just started

    This means that if you use anything that uses the_post() in *your* function that is triggered by loop_start, you end up in an infinite loop.

    So, if you wish to do a loop and run it before The_Loop, you have to creatively code it...i.e., you have to do your own loop using new instance of wp_query. All I'm saying is that this could be simplified by simply adding another action somewhere outside of the actual loop.

    Make sense?

    Posted: 9 years ago #
  4. Jen
    Key Master

    Closing thread b/c it's been open for a year with no supporting comments.

    Posted: 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.

  • Rating

    2 Votes
  • Status

    Sorry, not right now