Title: Reset query_posts?
Last modified: August 18, 2016

---

# Reset query_posts?

 *  [obeattie](https://wordpress.org/support/users/obeattie/)
 * (@obeattie)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/reset-query_posts/)
 * Is there a way of ‘resetting’ `query_posts`? I am using it within the sidebar
   to display 5 asides, but I still want the loop on the home page to display the
   number specified in the WordPress options.
 * **How could I cancel the first query_posts?**
 * Many Thanks in Advance,
    Oli

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

 *  [Peter Westwood](https://wordpress.org/support/users/westi/)
 * (@westi)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/reset-query_posts/#post-379547)
 * Have you read through the codex docs on [The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
   that should help you.
 *  Thread Starter [obeattie](https://wordpress.org/support/users/obeattie/)
 * (@obeattie)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/reset-query_posts/#post-379886)
 * No they don’t.. but I will have to manage and find a way around I suppose
 *  [Peter Westwood](https://wordpress.org/support/users/westi/)
 * (@westi)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/reset-query_posts/#post-379970)
 * The answer is there in that page.
 * You basically have a few different options on how to implement this depending
   on the order in which you want to run the multiple loops:
    1. Main post loop first followed by asides loop
    2. Asides loop first followed by main post loop
 * For 1, you can do the following after running the normal loop where you want 
   you asides loop you call `query_posts` to get the list of aside posting using
   the following code:
 * `// Get the last 5 posts in the asides_cat category.
    <?php query_posts('category_name
   =asides_cat&showposts=5'); ?> <?php while (have_posts()) : the_post(); ?> <!--
   Do asides stuff... --> <?php endwhile;?>
 * For 2, which I think is what you want from your description you need to be a 
   little more careful. If you call `query_posts` for the asides loop before displaying
   the normal loop it will overwrite the normal loops query and you won’t be able
   to display it easily. Therefore you have to create a new query object and use
   that as follows:
 * `<?php $my_query = new WP_Query('category_name=asides_cat&showposts=5'); ?>
    
   <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <!-- Do asides_cat
   stuff... --> <?php endwhile; ?>
 * You can then run your normal loop after this one for the asides.
 * Both these examples come from the codex docs [The_Loop#Multiple_Loops_Example_1](http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_1).

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

The topic ‘Reset query_posts?’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [reset](https://wordpress.org/support/topic-tag/reset/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Peter Westwood](https://wordpress.org/support/users/westi/)
 * Last activity: [20 years, 1 month ago](https://wordpress.org/support/topic/reset-query_posts/#post-379970)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
