Support » Themes and Templates » Loop Cancelled Out By Other Loop

  • Resolved kennethwatt


    Hi guys
    In my header, I have a list of recent posts. This should be controlled by its own loop:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    However, it shows whatever the page content is meant to be displaying; author pages showing the author’s posts, pages showing the page title, posts showing the post title.
    What should I change that code to to make sure it shows a list of the 6 latest posts?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Use <?php wp_reset_query(); ?> before making your call for next loop.
    Read more at:

    Hi there
    Not working I’m afraid.
    It’s like the actual request the page is making for which ever post it’s on, cancels out the header loop :S
    Thanks anyway 🙂

    Can you post the full code here.

    Sorry, tweaked it a bit to this:

    //The Query
    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title(); ?></a></li>
    <?php endwhile; else: ?>
     		<li>Something went bang... please try again later.</li>
    <?php endif;
    //Reset Query

    Thanks 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Loop Cancelled Out By Other Loop’ is closed to new replies.