Title: Incorrect $post variable breaks plugin
Last modified: August 31, 2016

---

# Incorrect $post variable breaks plugin

 *  Resolved [bkonia](https://wordpress.org/support/users/bkonia/)
 * (@bkonia)
 * [10 years ago](https://wordpress.org/support/topic/incorrect-post-variable-breaks-plugin-1/)
 * Some plugins mess with the global $post variable, resulting in it reporting a
   post type of “page”, for custom post types. This breaks your plugin because when
   it looks up the template for a custom post type page, it’s looking in the wrong
   category. The simplest way to work around this is rather than using the $post
   variable directly, do an additional lookup via the post ID.
 * $post_type = get_post_type($post->ID)
 * By the way, this issue is being tracked on github by another plugin developer:
 * github.com/mtekk/Breadcrumb-NavXT/issues/145
 * [https://wordpress.org/plugins/template-for-custom-post-types/](https://wordpress.org/plugins/template-for-custom-post-types/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Rahul Gandhi](https://wordpress.org/support/users/gandhirk/)
 * (@gandhirk)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/incorrect-post-variable-breaks-plugin-1/#post-7378241)
 * Hi Bkonia,
 * Thanks for the information. I will keep this in mind and will update it in next
   version of the plugin.

Viewing 1 replies (of 1 total)

The topic ‘Incorrect $post variable breaks plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/template-for-custom-post-types.svg)
 * [Template for Custom Post Types](https://wordpress.org/plugins/template-for-custom-post-types/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/template-for-custom-post-types/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/template-for-custom-post-types/)
 * [Active Topics](https://wordpress.org/support/plugin/template-for-custom-post-types/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/template-for-custom-post-types/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/template-for-custom-post-types/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rahul Gandhi](https://wordpress.org/support/users/gandhirk/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/incorrect-post-variable-breaks-plugin-1/#post-7378241)
 * Status: resolved