I think your first method isn’t working because it’s a theme method, not a plugin method. I could be entirely incorrect but I think the method of using single-custom_post_type.php
only works for themes. (Again, I 100% could be wrong.)
However, this is what I use and it always works:
function wpse_post_type_templates( $template ) {
if( is_singular( 'jdshs_jobs' ) ) {
$template = plugin_dir_path( __DIR__ ) . 'templates/jdshs-job-template.php';
}
return $template;
}
add_filter( 'single_template', 'wpse_post_type_templates', 50, 1 );
You can name the template file whatever you like, even single-jdshs_job.php
and essentially for every template, you just add it using the conditional checks. ie. is_archive( 'jdshs_jobs' )
etc.
Related Posts:
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- single-{$post_type}-{slug}.php for custom post types
- How to add custom content template part for a custom post type on main query using a plugin
- Adding a drag and drop re-ordering from a custom post type default list [closed]
- Filter for “get_post_type_archive_link()”
- How to add a button to custom post type’s posts-page
- Loading custom page template via plugin
- How to set a fall back template for a custom post type in a plugin?
- How often do you need to register_post_type?
- Unable to filter on field on edit.php page
- How to register custom post types in a plugin?
- Remove “Get Shortlink” button in admin of custom post type
- How do I set the link in the Custom Post Type admin menu?
- Modifying date filter on admin page for custom post type to link to custom field
- Insert Multiple Post with Same Publish Button
- Getting template_include to work when allow_url_include is off?
- Filter Posts from the Main Query
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- wordpress remove views from action links in a custom post
- Main query not querying any posts in custom taxonomy template
- Custom Empty Results page for my Custom Post Type
- sortable columns for multiple custom post types not working
- How do I add custom HTML to the content of an archive page’s posts?
- Assigning alternate single-{cpt} template based on blog_id in multisite
- Creating alternate meta box context locations
- Modify a plugin function output from another plugin
- Catch and display error on save_post action
- Best way to fix bad count on All | Mine | Published
- Plugin Development using classes – Public & Private Callbacks
- Store a value in global scope after init hook is fired
- Changing CPT permalink
- Dynamic page for nav items used as filters
- Warning , Use of undefined constant PLUGIN_PATH?
- Correct way to register custom post type from external php file?
- Insert custom taxonomy into category query
- get_permalink() of page the enclosing page not posts
- How can I load Template file from wordpress plugin
- call a function when insert and update a custom post type
- Execute code only after user clicks ‘update’ button for CPT being edited
- Adding Information To All Posts Screen
- Show Templates in Custom Post Type Editor
- Filter Content on all Post Types
- How to avoid hardcoded text in a custom page template?
- Hook only specific post type
- Change CPT Edit Target Link for Admin List
- tag.php doesn’t work with tags on a custom post type post?
- Assign single template to multiple custom post types?
- Add Content to Page without shortcodes
- Display posts of child category in template
- custom taxonomy – Template not working
- Pass A Value From Outside To A Plugin Variable
- What hook should be used to programmatically create a post only when master post is updated?
- Using posts and postmeta table to store custom Address Book Plugin data
- template_redirect not working, apparently for no reason
- wordpress 3.4 template files in subdirectories
- I am trying to output portfolio items with a picture. This code doesn’t seem to be working. What am I doing wrong?
- Help with CPT template pagination
- Merge multiple custom post types in a single archive template
- Custom Post Type | Fatal Error on register_post_type()
- Trying to edit the single page from a Custom Post
- Custom Post Type rewrite
- Admin notice not displaying
- Add custom column in custom post type edit page
- custom post type not showing in menu
- filter custom post type by meta key in dashboard
- Categories of custom taxonomy don’t show any posts
- Getting meta in editor plugin, and event triggering issue
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Limit number of custom posts per taxonomy
- How to use custom template files in deeper directory?
- How to use TinyMCE Editor for one of my custom post meta field?
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- How can I get this request to use the Custom Post Type page template instead?
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Save Multiple Metabox values
- Get rid of “trash can” for custom post type
- How can I use archive-{post_type}.php theme template?
- How exclude or skip post type with get_next_post_link
- Custom Post Type setup
- Custom Post Type homepage template
- Modifying WP_Title For Custom Post Type
- Types plugin custom post add_action hooks
- comments hooks on custom post type
- Not Able to Add New Class To CPT Attachment Image
- How to stop the custom post type URL from the google search?
- Display category filters for custom post type when category is shared by multiple post types
- Get all posts by many custom post types
- Create Post Types from a XML url (Real Estate website)
- Error when moving custom post type to bin
- custom data model – link and populate from admin backend
- Single taxonomy for different custom post types
- How should i name the .php file to show custom posts under a taxonomy’s term?
- template structure for CPT not clear
- Having some trouble properly displaying Custom Post Types in templates
- Get term_id for each instance of custom taxonomy
- query_post while (have post) get_template_part()?
- WordPress Roles
- How to separate posts by categories?
- Make term slugs of custom taxonomy available in WP REST API for custom post type?