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: https://develop.svn.wordpress.org/trunk@14607 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood
2010-05-13 20:39:54 +00:00
parent e35fe8d6d9
commit 728b90a13b
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();