[wp-trac] [WordPress Trac] #37312: Invalid call to wp_reset_postdata inside Recent Posts widget
WordPress Trac
noreply at wordpress.org
Fri Jul 8 01:35:32 UTC 2016
#37312: Invalid call to wp_reset_postdata inside Recent Posts widget
---------------------------+-----------------------------
Reporter: peterwilsoncc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
If the global post object is from a query other than the main query, the
recent posts widget will restore the wrong post object by calling
`wp_reset_postdata`.
{{{#!php
$my_query = new WP_Query( $args );
$my_query->the_post();
// $GLOBALS['post'] is first post of $my_query
the_widget( 'WP_Widget_Recent_Posts' );
// $GLOBALS['post'] is restored to the main query's last accessed post
}}}
Introduced in [14607] following #12320.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37312>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list