Support » Themes and Templates » Multiple Loop Not resetting

  • Resolved mvlaver


    Hi guys hope you can help with this.

    I have two loops in my sidebar to show latest newsletter and latest podcast.

    This is the first one

    <?php $latestnewsletters = new WP_query('showposts=1&category=5'); ?>
    	<?php while ($latestnewsletters->have_posts()) : $latestnewsletters->the_post(); ?>
    		<li class="newsletter"><a href="<?php echo get_post_meta($post->ID, 'newsletter_pdf', true ); ?>">Newsletter from <?php the_title(); ?></a></li>
    	<?php endwhile; ?>

    Which is followed directly by

    <?php $latestpodcast = new WP_query('showposts=1&category=3'); ?>
    	<?php while ($latestpodcast->have_posts()) : $latestpodcast->the_post(); ?>
    		<li class="podcast"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    	<?php endwhile; ?>

    The problem is that the second loop is showing the results of the first one. i.e. the_title of the second one is showing me a title from the first one.

    Anybody know what I am doing wrong. Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael


    Forum Moderator

    try to use <?php wp_reset_query(); ?> after each loop.

    Didn’t help I’m afraid. Any other suggestions?

    All right I’m just being an idiot sorry to waste your time. It’s because there isn’t such a parameter as ‘category’. It should be ‘cat’. Which means both queries were just giving me the same result from the pages initial query – rahr!

    Oh well hope this helps someone.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Loop Not resetting’ is closed to new replies.