wp_reset_postdata

Definition:
function wp_reset_postdata() {}

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

Source code

function wp_reset_postdata() {

	global $wp_query;

	if ( !empty($wp_query->post) ) {

		$GLOBALS['post'] = $wp_query->post;

		setup_postdata($wp_query->post);

	}

}

4055

No comments yet... Be the first to leave a reply!

Leave a comment