wp_reset_query

Definition:
function wp_reset_query() {}

Destroy the previous query and set up a new 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.

Source code

function wp_reset_query() {

	unset($GLOBALS['wp_query']);

	$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];

	wp_reset_postdata();

}

4057

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: