How does reset_postdata restore the post of the main query loop?
WP_Query::reset_postdata() sets the global post variable ($GLOBALS[‘post’] === $post) to the current post in the loop of the current WP_Query instance. public function reset_postdata() { if ( ! empty( $this->post ) ) { $GLOBALS[‘post’] = $this->post; $this->setup_postdata( $this->post ); } } What that means is that, if you run a custom query on a page, … Read more