It turns out that $wp->query_vars[“post_type”] contains the data I need, regardless of whether the request method is GET or POST.
namespace mynamespace;
class MyPlugin {
public static function template_include($template) {
global $wp;
if ($wp->query_vars["post_type"] == 'thing') {
return plugin_dir_path( __FILE__ ) . 'templates/thing.php';
}
return $template;
}
}
add_filter('template_include', '\mynamespace\MyPlugin::template_include');
Also, it appears that the reason this problem occurred in the first place is because I had named a field in the form with the same name as the custom post type. If I name the form field something different, then there is no issue.
Related Posts:
- Twillio How To Send SMS for Custom Post Type
- What hook can I use to modify custom post data before it is displayed on the page?
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- save_post hook partly firing in update post
- Remove H1 title in admin post edit screen
- Tips for using WordPress as a CMS? [closed]
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- Custom Post Type Templates from Plugin Folder?
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- Implementing a CrunchBase.com Clone using WordPress?
- How can I see all the actions attached to an “add_action” hook?
- Registering Class methods as hook callbacks
- How to customize woocommerce related products? [closed]
- How to include code only on specific pages?
- Changing the “Plugin Activated” Message Default
- Hooking in to plugins
- Custom media upload content for inserting custom post shortcode
- Generate dormant hook references
- Redesigning Custom Post Type “Add New” page
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Schedule WordPress Auto-Updates to only run during business hours
- How to share category taxonomy with custom post type (The Event Calendar plugin)
- Is it possible to define a template for a custom post type within a plugin independent of the active theme?
- Better to fire specific hooks or generic hooks with parameters?
- How to get a variable number of posts per post type on the main loop?
- How to only hook on Single.php after content?
- Remove action from plugin on other plugin
- Why does wp_enqueue_style() in plugin not load stylesheet?
- Preventing a plugin from updating
- WP_query parameters for date range
- Use a plugin to handle custom post types?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Is there any debug toolbar that shows whick hooks are called for the current page in WordPress?
- When can you get current page ID and initialize hooks right after?
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- Customizing subject in comment notification e-mails
- How to save the values of checkbox to the register setting?
- Can we hook a static method of a class to add_action inside that class?
- Edit plugin without hooks in functions.php
- Creating a default Custom Post Template that a Theme can override
- How can I log a user out of WordPress before the page loads?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- WP showing “warning: call_user_func_array()”, What to do?
- Filter out results from REST API
- How can I remove a hooked action created by a plugin?
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- Filter Hook on plugin update
- How often do you need to register_post_type?
- Jetpack plugin (ShareDaddy): Prevent share buttons showing on custom post types?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Modify featured image URL at runtime
- WordPress Hook that will run when media file deleted
- Seeking clarification on page request life-cycle
- Disallow a user to post in certain categories
- Getting Custom Post Type content from main-site of a Multisite
- Intercepting a add_action
- Generic plugin (de)activation hook?
- Custom database or Custom Post Types?
- Which hook should be used to validate custom form fields on the login form?
- How to make a list of companies’ information and display them to user, using custom post types and a custom taxonomy?
- Custom comment type maybe?
- Register Custom Post Type from Plugin
- Prevent page slug from interfering with custom post type archive permalink?
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- disable active plugins for specific theme
- Add .html extension to custom post type taxonomies
- How to load a new template page according to a particular URL?
- Hook (upgrader_process_complete) running moment
- Adding a form at the end of the content
- Hide WordPress Plugin Deactivation Links
- How to get the custom page get_permalink?
- Updating post meta for custom post types
- Find out if request is for custom post type archive before query runs
- Use external link in the add sub menu
- Pass A Value From Outside To A Plugin Variable
- Seriously stuck with some custom meta box/plugin stuff
- Template for custom post type shows all posts instead of just one
- Themes VS Plugins [duplicate]
- Built in admin ajax hooks?
- Failed to invoke other hook from the init hook
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- How can I add a custom meta value on file upload?
- Adding dynamic section to WordPress
- remove custom taxonomy metabox form custom post type
- Enable comments for post with comments meta box removed
- [Plugin: Posts 2 Posts] reciprocal connections
- Custom Post Type Statuses
- How to Build a Movie Library in WordPress 3.x
- do_action and hook methods
- Custom Post Type causes Page Not Found
- How do I get multiple pages by title?
- the_posts hook, which set of posts?
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- How to register custom post types in a plugin?
- Fatal error: Class not found in
- Is it possible to add an action to the currently running action?