wp_reset_query

Destroys the previous query and sets up a new query.

Description

wp_reset_query(); 

This should be used after query_posts() and before another query_posts(). This will remove obscure bugs that occur when the previous WP_Query object is not destroyed properly before another is set up.


Usage

  1. if ( !function_exists( 'wp_reset_query' ) ) { 
  2. require_once ABSPATH . WPINC . '/query.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_reset_query(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/query.php  
  1. function wp_reset_query() { 
  2. $GLOBALS[wp_query] = $GLOBALS['wp_the_query'];