Title: query_posts before the loop
Last modified: August 19, 2016

---

# query_posts before the loop

 *  Resolved [dcole07](https://wordpress.org/support/users/dcole07/)
 * (@dcole07)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/query_posts-before-the-loop/)
 * I inserted a query_posts() before the loop to insert a post and it messed up 
   the loop by replacing the loop’s posts with the post from the code I added. How
   can I avoid having the first get posts in the header not effect the one in the
   loop.

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

 *  Thread Starter [dcole07](https://wordpress.org/support/users/dcole07/)
 * (@dcole07)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/query_posts-before-the-loop/#post-977683)
 * I checked out [http://codex.wordpress.org/The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
   but none of the methods worked for some reason.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/query_posts-before-the-loop/#post-977686)
 * There’s a number of examples out there. Here’s one to review:
    [http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/](http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/)
 *  Thread Starter [dcole07](https://wordpress.org/support/users/dcole07/)
 * (@dcole07)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/query_posts-before-the-loop/#post-977689)
 * Turns out the answer is as simple as calling `wp_reset_query();`

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

The topic ‘query_posts before the loop’ is closed to new replies.

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [dcole07](https://wordpress.org/support/users/dcole07/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/query_posts-before-the-loop/#post-977689)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
