[wp-trac] [WordPress Trac] #12320: Invalid call to wp_reset_query() inside Recent Posts widget

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 25 12:26:31 UTC 2010


#12320: Invalid call to wp_reset_query() inside Recent Posts widget
--------------------------+-------------------------------------------------
 Reporter:  michelwppi    |       Owner:  azaozz              
     Type:  defect (bug)  |      Status:  new                 
 Priority:  normal        |   Milestone:  3.0                 
Component:  Widgets       |     Version:  2.9.2               
 Severity:  normal        |    Keywords:  has-patch query loop
--------------------------+-------------------------------------------------

Comment(by michelwppi):

 Replying to filosofo

 I'' am not sure if it is here the right place to go deep about loops''
 (main and others) and loop in loop (codex:
 [http://codex.wordpress.org/The_Loop]) and loops in sidebar or elsewhere.
 But I will try to be more explicit.

 As described above and as well understood by scribu, the reset of global
 $wp_query is not justified here inside default - ''lastest posts widget''
 -. Perhaps only the global $post is wished. [[BR]]
 It is easy to confirm by tests and different themes. Depending of
 architecture of theme's files, the place of the function
 '''get_sidebar()''' - and the call of '''dynamic_sidebar()''' is
 ''crucial'' to see the bad effects of the unwished reset. [[BR]]
 When the call of this function get_sidebar() building the widgets is after
 the main loop is accomplished, nothing occurs.

 BUT is the call is before (''by example just after the call of
 get_header()'') and if the default query (home by example) is completed
 (via a filter) by a '''query_posts()''' call (by example to affine query
 according detected browser), the unwished big reset cancel this query
 addition and the main loop will begin with the very first query.[[BR]]

 In more general terms, a widget must not interfere with his environment
 especially shared global vars. See above in original ticket the temporary
 workaround.

 Best regards, Michel of  http://dev.xiligroup.com

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12320#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list