wp_reset_postdata

After looping through a separate query, this function restores the $post global to the current post in the main query.

Description

wp_reset_postdata(); 

Usage

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

Defined (1)

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

/wp-includes/query.php  
  1. function wp_reset_postdata() { 
  2. global $wp_query; 
  3.  
  4. if ( isset( $wp_query ) ) { 
  5. $wp_query->reset_postdata();