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
- How can I allow plugin users to define layouts for a custom post type
- Add block templates (html) via plugin for custom post type
- detect your custom post type in WordPress
- Custom posts template page
- Use remove_meta_box conditionally on custom post type
- ACF in wordpress
- Theme independent plugin by using default page template
- Option page’s form doesn’t work
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data
- How can I use archive-{post_type}.php theme template?
- hook filter after the_content on a specific page
- post_parent in custom post type
- Custom Meta fields Update hook?
- Bind a function with its own argument to show something dynamically after every content
- How to group navigation items in the admin panel
- wp_trash_post action hook with custom post type
- What’s an efficient way to change the post status of many posts at once?
- Filter posts by tax (dropdown) and meta value
- How do I amend form data before it is saved for a custom post type
- Add an Outside Wrapper to my Header and Make it Full Width
- make permalink go to a custom single.php file
- Add Previous/Next Buttons to CPT Single Pages Only
- Creating Sections for Post Types
- Custom post types with categories in template
- How can I include active content in a custom post type?
- How can I remove filters from custom post types?
- Creating separate feeds for custom post types
- Which file/template is in charge of taxonomies for custom post types?
- Dynamically insert code to custom post type loop
- Show current custom taxonomy
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- How can I trace inconsistency in loading a template?
- Hook add_attachment error
- How to insert data into meta box from another plugin?
- Call to undefined function is_home() or any conditional tags
- How exclude or skip post type with get_next_post_link
- How check if a post is saved from backend or frontend?
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- How to access the thank you page from the single post?
- Update variable value via add_filter
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- REST filters only firing when I have a param set
- How do you make a list and list item relation if custom post types?
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- How to get_term_meta on single custom post?
- ajax response not recieving
- How to build a WordPress post review system beside commenting
- Add form after woocommerce admin order edit
- WordPress hook after post content and meta update
- ACF for custom post type archive pages: which hook to use?
- Custom Meta Box returns no HTML
- WordPress hook which triggers on post import