From 22bee1c9d7c136374fa8c041d40f4e055719748f Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 9 Nov 2006 06:50:58 +0000 Subject: [PATCH] Preserve the original query object as wp_the_query so that it's not stomped by subsequent calls to query_posts(). git-svn-id: http://svn.automattic.com/wordpress/trunk@4460 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/classes.php | 3 ++- wp-includes/query.php | 5 +++-- wp-settings.php | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 3de85c88d..c27b2fcbd 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -249,8 +249,9 @@ class WP { } function query_posts() { + global $wp_the_query; $this->build_query_string(); - query_posts($this->query_vars); + $wp_the_query->query($this->query_vars); } function handle_404() { diff --git a/wp-includes/query.php b/wp-includes/query.php index e8dd9d6f0..c544dd336 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -11,8 +11,9 @@ function get_query_var($var) { } function &query_posts($query) { - global $wp_query; - return $wp_query->query($query); + unset($GLOBALS['wp_query']); + $GLOBALS['wp_query'] =& new WP_Query(); + return $GLOBALS['wp_query']->query($query); } /* diff --git a/wp-settings.php b/wp-settings.php index be76c5428..e6559bcfe 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -226,9 +226,10 @@ $_SERVER = add_magic_quotes($_SERVER); do_action('sanitize_comment_cookies'); -$wp_query = new WP_Query(); -$wp_rewrite = new WP_Rewrite(); -$wp = new WP(); +$wp_the_query =& new WP_Query(); +$wp_query =& $wp_the_query; +$wp_rewrite =& new WP_Rewrite(); +$wp =& new WP(); validate_current_theme(); define('TEMPLATEPATH', get_template_directory());