[wp-trac] [WordPress Trac] #18408: Can't wp_reset_postdata after custom WP_Query in an admin edit page

WordPress Trac noreply at wordpress.org
Fri Sep 18 03:50:21 UTC 2015


#18408: Can't wp_reset_postdata after custom WP_Query in an admin edit page
-------------------------------------------+-----------------------------
 Reporter:  ericlewis                      |       Owner:  ericlewis
     Type:  defect (bug)                   |      Status:  reopened
 Priority:  normal                         |   Milestone:  Future Release
Component:  Query                          |     Version:  3.8.1
 Severity:  normal                         |  Resolution:
 Keywords:  has-patch needs-testing close  |     Focuses:
-------------------------------------------+-----------------------------
Changes (by wonderboymusic):

 * keywords:  has-patch needs-testing 2nd-opinion => has-patch needs-testing
     close


Comment:

 I can't begin to imagine what would break if we did:

 {{{
         global $wp_query;

         if ( isset( $wp_query ) ) {
                 $wp_query->reset_postdata();
         } else {
               // CODE that is certain to break untold # of plugins and
 themes
         }
 }}}

 Globals are super-fragile. I don't think we should start actively
 supporting theme functions and nested loops with proactive reset on this
 screen. You're better off toggling the global `$post` in your own code
 here.

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


More information about the wp-trac mailing list