Home > Not Working > Wp_reset_postdata Vs Wp_reset_query

Wp_reset_postdata Vs Wp_reset_query


I was doing so with WP_Query but found that it was breaking the edit screen in that the editable content was being pulled from the last post in my list of This is useful when using WP_Query to customize loops or create multiple loops on the same page. Simple geometry. This will modify the global $post variable. Source

But in the case of post.php, there is no main query - the $post global is populated manually, using get_post(), rather than through the normal $wp_query loop. Had to change the $context in my meta_box to "normal" or keep default setting "advanced". #23 in reply to: ↑ 22 @Mekku 6 months ago Replying to hungpham: I am just facing Smashing WordPress » 3 Ways to Reset the WordPress Loop Posted by Jeff Starr • Updated on September 14th, 2013 WordPress does an excellent job of keeping track of what's happening more hot questions question feed default about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation

Wp_reset_postdata Vs Wp_reset_query

When should I use them? The root issue is that wp_reset_postdata() is designed to reset globals to match the main query. wp_reset_postdata() wp_reset_query() rewind_posts() Quick Summary wp_reset_postdata() First up we have wp_reset_postdata, which restores the global $post variable to the current post in the main query.

Smashing WordPress » 11 Responses Abhishek September 13, 2011 Whooaaaa…. Examples 3 ); // the query $the_query = new WP_Query( $args ); ?> have_posts() ):?>