Title: When to use Reset Query
Last modified: August 19, 2016

---

# When to use Reset Query

 *  [jeremiahjobe](https://wordpress.org/support/users/jeremiahjobe/)
 * (@jeremiahjobe)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/when-to-use-reset-query/)
 * I am excluding posts in a particular category from pages that use the _index.
   php_ as a template using `query_posts()`. It’s the only way I have found to exclude
   posts from a category that isn’t a plug-in and doesn’t mess up something else
   on my site.
    Here’s the code I have:
 *     ```
       <?php query_posts($query_string . '&cat=-3'); ?>
         <?php if (have_posts()) : ?>
       ```
   
 * My question is whether it is necessary to reset query after the loop, which would
   look like this:
 *     ```
       <?php endif; ?>
          <?php wp_reset_query(); ?>
       ```
   
 * Is there a benefit or drawback to this? On a basic level I understand what the
   reset is doing, but as far as best practices – should the query be reset every
   time I use `query_posts()` (since I’m changing the state of the query)or is there
   a rule of when to use and when not to use?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/when-to-use-reset-query/#post-1107887)
 * No, it’s not a bad thing–essentially wp_reset_query resets back to before you‘
   mucked’ with the query. In fact, wp_reset_query is found in at least one of the
   built-in widgets.
 * Original ticket:
    [http://core.trac.wordpress.org/ticket/4741](http://core.trac.wordpress.org/ticket/4741)
 *  [mjritter](https://wordpress.org/support/users/mjritter/)
 * (@mjritter)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/when-to-use-reset-query/#post-1108166)
 * I am displaying a main video post, then next to the displayed video there is 
   a jquery carousel with about 40 videos. below the jquery carousel, i have social
   network share buttons that are supposed to let you share the the main video post.
   however, they are linking to the last video in the carousel.
 * should i use wp_reset_query(); ? it doesn’t seem to be working.

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

The topic ‘When to use Reset Query’ is closed to new replies.

## Tags

 * [?cat](https://wordpress.org/support/topic-tag/cat/)
 * [category](https://wordpress.org/support/topic-tag/category/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [mjritter](https://wordpress.org/support/users/mjritter/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/when-to-use-reset-query/#post-1108166)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
