WordPress at a glance
function is not described

WP_Query::reset_postdata() WP 3.7.0

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

This is a method of the class: WP_Query

  • Global. WP_Post. $post

No Hooks.


Nothing (null).


$WP_Query = new WP_Query();
$var = $WP_Query->reset_postdata();

Code of WP Query::reset postdata: wp-includes/class-wp-query.php WP 5.2

public function reset_postdata() {
	if ( ! empty( $this->post ) ) {
		$GLOBALS['post'] = $this->post;
		$this->setup_postdata( $this->post );