# Multiple loops on the same page removing post tags

I am trying to use two loops on my page, one to get the current page's content and so on, and another to get all of the posts of a specific category.

When I do that, all of the tags for the current page disappears.

Here is my code,

Loop one:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="content_wrapper"><?php the_content(); ?></div>
<?php endwhile; ?>
<?php endif; ?>


Loop two:

<?php query_posts(array('category_name' => 'test')); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div><?php the_excerpt(); ?></div>
<?php endwhile; ?>
<?php endif; ?>


Any ideas?

-
Whoops, forgot to reset the query after query_posts with wp_reset_query, after adding that it works now. –  Odyss3us Mar 9 '11 at 19:24
Well spotted though, i like how you spotted your error and corrected it(and posted it back here in the question), you've scored one in my book... ;) –  t31os Mar 9 '11 at 21:18

Odyss3us, I have read a lot about multiple queries lately and it seems there is a lot of bad practice floating around about the best way to include multiple loops in a single page. Take a look at this for reference on why you should be using WP_Query instead of query_posts. There is less risk of causing havoc using WP_Query, which query_post calls anyway. Hope this sheds some light for other readers as well.

-

Sorry guys, stupid mistake, I forgot to reset the second loop using wp_reset_query, here is the working code,

<?php query_posts(array('category_name' => 'test')); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div><?php the_excerpt(); ?></div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>


Thanx anyways though!

-