Introduce wp_reset_postdata(). Use it to reset the post global for the current query_posts() call after using a loop with a new WP_Query object. Fixes #12320 props scribu.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi
2010-05-13 20:39:54 +00:00
parent 742db4bc22
commit 08fc51b214
2 changed files with 14 additions and 1 deletions

View File

@@ -554,7 +554,9 @@ class WP_Widget_Recent_Posts extends WP_Widget {
</ul>
<?php echo $after_widget; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
endif;
$cache[$args['widget_id']] = ob_get_flush();