Title: Resetting Post Data
Last modified: August 30, 2016

---

# Resetting Post Data

 *  Resolved [Andrew Tegenkamp](https://wordpress.org/support/users/andrewteg/)
 * (@andrewteg)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/resetting-post-data/)
 * I’d like to ask that you consider adding `wp_reset_postdata();` ([https://codex.wordpress.org/Function_Reference/wp_reset_postdata](https://codex.wordpress.org/Function_Reference/wp_reset_postdata))
   to the end of your shortcode functions in \plugins\quick-restaurant-menu\includes\
   shortcodes.php so that it does not conflict with other plugins that read the 
   main query of the post or page after the shortcode.
 * I have added it to my site and it helps a sidebar plugin that is based on the
   post/page being shown for example. I put it just before the `return $html` code
   and am hoping this can be in a future update to provide more compatibility with
   other plugins.
 * If there is a reason you don’t recommend this, could you let me know?
 * Thanks,
    Andrew
 * [https://wordpress.org/plugins/quick-restaurant-menu/](https://wordpress.org/plugins/quick-restaurant-menu/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Alejandro](https://wordpress.org/support/users/alejandropascual/)
 * (@alejandropascual)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6312949)
 * Yes, you are right.. I’ll add it in the next release.
    Many thanks Alejandro
 *  Plugin Author [Alejandro](https://wordpress.org/support/users/alejandropascual/)
 * (@alejandropascual)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6313141)
 * 🙂
 *  Plugin Author [Alejandro](https://wordpress.org/support/users/alejandropascual/)
 * (@alejandropascual)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6313182)
 * Hi Andrew:
    With the shortcode I’m not altering the main query as I’m not using
   WP_Query, so wp_reset_postdata() is not needed. Why do you think it’s needed ?
   Thanks Alejandro
 *  Thread Starter [Andrew Tegenkamp](https://wordpress.org/support/users/andrewteg/)
 * (@andrewteg)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6313183)
 * I believe it is because the function erm_shortcode_menu calls `global $post;`
   and then in the foreach it sets `$post = get_post( $item_id );` which alters 
   the $post variable. So $post at before the function shortcode is different than
   $post after the shortcode. This is the same effect as WP_Query even though it
   is not called, so wp_reset_postdata() fixes it.
 * I think if in the foreach the $post got renamed to something like $post_menu 
   or $post_item then you would not need wp_reset_postdata(). I know [https://codex.wordpress.org/Function_Reference/WP_Query](https://codex.wordpress.org/Function_Reference/WP_Query)
   talks about the global $post variable almost like a reserved variable for WordPress.
 * I hope that helps and makes at least some sense 🙂
 * Thanks,
    Andrew
 *  Plugin Author [Alejandro](https://wordpress.org/support/users/alejandropascual/)
 * (@alejandropascual)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6313184)
 * Yes, right.. I’ll change that, it has all the sense, … I always use $the_post,
   never $post, sure it was late that day.. Many thanks 😀

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Resetting Post Data’ is closed to new replies.

 * ![](https://ps.w.org/quick-restaurant-menu/assets/icon-256x256.png?rev=1172762)
 * [Quick Restaurant Menu](https://wordpress.org/plugins/quick-restaurant-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/quick-restaurant-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/quick-restaurant-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/quick-restaurant-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/quick-restaurant-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/quick-restaurant-menu/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Alejandro](https://wordpress.org/support/users/alejandropascual/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/resetting-post-data/#post-6313184)
 * Status: resolved