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
- Tips for using WordPress as a CMS? [closed]
- Registering Class methods as hook callbacks
- How to customize woocommerce related products? [closed]
- Edit plugin without hooks in functions.php
- How can I log a user out of WordPress before the page loads?
- Modify featured image URL at runtime
- Seeking clarification on page request life-cycle
- How to make a list of companies’ information and display them to user, using custom post types and a custom taxonomy?
- Pass A Value From Outside To A Plugin Variable
- Built in admin ajax hooks?
- remove custom taxonomy metabox form custom post type
- [Plugin: Posts 2 Posts] reciprocal connections
- Custom Post Type Statuses
- add_meta_box Callback not being called
- How to find out what blocks are added by a plugin
- Get image URL from media library in input
- what the hook for displaying course list page for learndash plugin? [closed]
- What are the benefit in adding hook in the init() hook?
- What are ideal hooks to call register_sidebars?
- wordpress reusable content blocks
- Deactivate Plugin on Theme Switch
- Where to hook my plugin’s action
- how do i remove posts from a WP_Query so the pagination is right?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Accessing post’s meta data based on user’s click of a post
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Add custom message to the plugins page of WordPress
- Plugin custom post type – Internal server Error
- List taxonomy terms for post as checkboxes
- Hooking in to replace the Sidebar/Widget areas
- How to get all of the activate_plugin action parameters?
- Matching Chapters to a Custom posts [closed]
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- do_action() hook into load-(page)
- Mq translate plugin custom post type issue
- Howto check version of another plugin and then add a submenu page to it
- Why do plugins often ask to add in to templates?
- How to get menu location in wp_update_nav_menu hook
- WooCommerce: after install hook
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- wp_trash_post hook – problem with page updating if using wp_die
- is it possible to hook every page style?
- Comment Approve – Add custom function when comment is approved
- Add action to custom Function
- How can I list custom post type categories of portfolio
- “Allowed memory size” problem [closed]
- Plugin Hook When New Author Added
- Custom Post Type, Custom Columns List
- How to create repeater field manually, without plugin (ACF Pro)?
- how to create hierachial taxonomy and manage under single post type?
- need click to clipboard button on my site
- Setting Author on CPT
- Check if theme supports sidebar
- Fail on admin_enqueue_scripts when I try it to upload a CSS file to my WordPress Plugin
- Adding category base to url in custom post giving 404?
- How to remove a hook written with $this?
- update_option_{$option} not working (do function after options are saved)
- Alternative Hook to the_content for Changing Background Color
- Unpublished Pages Failing To Appear On Custom Path
- Problem with checked box on wp car manager plugin
- WordPress hide post from custom post-type on a single page
- ACF Fields are not showing up on Homepage
- Hooking into the HTML header container
- Hide WordPress Site URL from Source Code
- When/where would want to attach other classes to the base class in a WordPress plugin?
- Plugin function in child theme
- Edit plugin’s HTML output with Hooks
- {status}_{post_type} does not run correctly?
- Why is WP template_include overwritting all templates rather than specified page?
- Identify if the_post hook is being called from the admin post list
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Creating Custom Hook for my plugin
- Passing a parameter to filter and action functions
- WordPress hook source
- Manually return false for function_exists
- How to `remove_action` from plugin
- Creating themes using the one Plugin (Toolkit)
- How to add jquery to my custom post type wp plugin
- WordPress list child pages of custom post type
- Transition Post status not working
- functions.php conditional output for a single plugin
- Create custom fields on a post
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- How to make plugin work in each template in wordpress
- OOP Plugin: Where should I place the action hooks in the class?
- How can I default a new post to being saved?
- Change the behaviour of archive cpt category and single cpt by plugin, not by theme
- A plugin for software reviews site like this one?
- WordPress show different custom post type
- Neither update_option nor delete_option fires in deactivation hook
- How to export post tags from wordpress
- How to access the page without registering in wordpress
- CPT template is not being automatically used single post pages
- Set the title of a custom post automatically by using info from custom fields?
- public custom posts not showing in my wordpress plugin
- plugin translation *.mo file not getting loaded for custom post