[wp-trac] [WordPress Trac] #30273: WP_Query with admin_bar_menu resets $post

WordPress Trac noreply at wordpress.org
Thu Nov 6 19:10:06 UTC 2014


#30273: WP_Query with admin_bar_menu resets $post
--------------------------+-----------------------------
 Reporter:  jag1989       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Query         |     Version:  4.0
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  administration
--------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  reporter-feedback => needs-patch
 * milestone:  Awaiting Review => Future Release


Comment:

 Replying to [comment:2 jag1989]:
 > I have just checked out the latest truck and the same issue still
 occurs.
 >
 > Issue happens only in the back-end on the following pages:
 > Edit/New Post
 > Edit/New Page

 Ah, thanks for these additional details. It's happening on these pages and
 not others because the `$post` global on `post.php` is not populated by a
 `WP_Query` (which cleans up after itself). We'll need to introduce some
 additional logic into `WP_Query` to stash the content of the global before
 replacing it, and then put it back after the loop is finished. This logic
 already exists for nested queries (inside of `reset_postdata()`) but it
 doesn't work when `$post` has been manually set, as on post.php.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30273#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list