There re various filters you can use to inject your custom template. One being the template_include
, the other single_template
, and even type_template
.
The easiest one would be single_template
in your case (example from codex):
function get_custom_post_type_template($single_template) {
global $post;
if ($post->post_type == 'my_post_type') {
$single_template = dirname( __FILE__ ) . '/post-type-template.php';
}
return $single_template;
}
add_filter( 'single_template', 'get_custom_post_type_template' );
Related Posts:
- Template for specific post of custom post type
- How do I create new content pages for my Custom Post Type?
- How to show the archive / post type description on Single templates
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Function to allow single post template based on custom taxonomy?
- Conflict in function to allow single post template based on category
- Assign for all post of a post type a specific single-post template
- DIVs not showing correctly on CPT?
- How to disable the single view for a custom post type?
- Can I assign a template to a custom post type?
- Get custom post_type’s archive URL
- Custom post type single page returns 404 error
- single-{$post_type}-{slug}.php for custom post types
- Custom post type single-{custom}.php not working
- What is singular.php?
- Conditional for single-{post-type}.php
- Searching multiple custom post types and pages
- display different template based on post type
- Taxonomy, Terms, and Template Files
- previous_post_link() and next_post_link() with a custom post type?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- tag.php doesn’t work with tags on a custom post type post?
- Setting a custom sub-path for blog without using pages?
- Custom Post Types 404 Issue
- How to add custom content template part for a custom post type on main query using a plugin
- Assign single template to multiple custom post types?
- Add Content to Page without shortcodes
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Single custom post type page redirecting to 404 page
- Loading custom page template via plugin
- Multiple Single Post templates
- How to set a fall back template for a custom post type in a plugin?
- Templates for Custom Post Types and Custom Taxonomies
- Using Templates with Custom Post Type UI
- Get page by template?
- Pre get posts for single post
- Custom taxonomy query for a custom post type
- Apply template to custom post type
- Page is defaulting to archive page and not designated template
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- is_singular() not working if called via callback function of admin-ajax.php
- How to quickly switch custom post type singular template?
- Disable Single Post View for Specific Taxonomy on Custom Post Type
- How to list/show all custom post types regardless of category?
- Custom Post Type Archive URL takes over page URL
- Need some templating advice for templating with custom post types and taxonomies
- How to query custom posts using a dynamic category
- Using Custom Templates for Custom Post Types for the Genesis Theme Framework?
- Custom Post Type with Nested Taxonomy and Template Files
- Custom Post Type Archive Template
- Custom templates for posts like for pages: page-{id} vs single-{id}
- How to get a list of term names of the custom post type im currently on in single.php
- Posts in Multiple Columns and Rows with one single loop
- is_singular won’t call my functions?
- Create sub single pages
- Using previous_post_link and next_post_link to wrap around post sequence
- Create Pages from Database
- Custom page type – template under page attributes?
- Template tags to display custom post type posts in category template?
- Display different gutenberg template from selected post attributes
- Clean URL permalink for custom post type
- custom post type archive template per custom taxonomy term
- where can I see my custom post type archive template?
- Custom post type loops with different page templates
- Display “Post 2 of 4” on single post page?
- posts_nav_link on single post template
- Display posts of child category in template
- custom taxonomy – Template not working
- Post Rank on Single Post page based on custom field
- Disable single pages and archives and keep preview
- Include different loop templates in search query
- Create separate template for shared custom taxonomy with shared terms
- Single page template for custom post_type
- Displaying Meta Box Image
- Trying to manage templates on a blog with lots of custom taxonomies
- Custom template for post type not working
- Make custom post type display as a page
- Custom Post Type Templates?
- Turn query string to sub page
- Remove header and footer but KEEP all css and js etc for a custom post template?
- WordPress Template Hierarchy
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- wordpress 3.4 template files in subdirectories
- Pagination Issue: Custom Post Type In Index
- Lock post meta block at the bottom of a custom post type
- Create second custom 404 page for selected post type
- How do I provide a “show all posts” link in a paginated term archive?
- is_page_template not working as expected
- I am trying to output portfolio items with a picture. This code doesn’t seem to be working. What am I doing wrong?
- Disable single view in register_post_type [duplicate]
- Help with CPT template pagination
- How can I force custom post type to use a specific template?
- Archive page for custom post type not working
- Redirect Single Post CPT (Custom Post Type) to a specific URL
- Multiple templates for a custom post type
- Need post_type_archive_title function but in ‘single’
- Merge multiple custom post types in a single archive template
- Trying to edit the single page from a Custom Post
- pagination redirecting from page number url before page requested