[wp-trac] [WordPress Trac] #4741: Multiple $wp_query objects mess a lot of things up

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 13 18:34:22 GMT 2007


#4741: Multiple $wp_query objects mess a lot of things up
----------------------------+-----------------------------------------------
 Reporter:  mdawaffe        |       Owner:  anonymous  
     Type:  defect          |      Status:  new        
 Priority:  normal          |   Milestone:  2.3 (trunk)
Component:  Administration  |     Version:  2.2.2      
 Severity:  normal          |    Keywords:             
----------------------------+-----------------------------------------------
 Many themes call query_posts() one or more times, each overwriting the
 previous $wp_query object. Unless we're super careful, this can break a
 lot of stuff.  To get back to the original query, I find myself doing

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

 a lot.

 I propose a new wp_reset_query() function that replaces $wp_query with the
 original $wp_the_query.  It might prove useful to attach that function to
 the wp_footer action.  It'd probably actually fix a lot of custom stuff
 out there that no one knew was broken, but it'd likely also break a few
 things for people.

 Attached adds the function and no more.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4741>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list