Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 6 years ago

#4741 closed defect (bug) (fixed)

Multiple $wp_query objects mess a lot of things up

Reported by: mdawaffe's profile mdawaffe Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2.2
Component: Administration Keywords:
Focuses: Cc:

Description

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.

Attachments (1)

4741.diff (399 bytes) - added by mdawaffe 17 years ago.

Download all attachments as: .zip

Change History (5)

@mdawaffe
17 years ago

#1 @westi
17 years ago

+1

This sounds like a really useful function.

#3 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5907]) wp_reset_query() from mdawaffe. fixes #4741

This ticket was mentioned in Slack in #cli by magicroundabout. View the logs.


6 years ago

Note: See TracTickets for help on using tickets.