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?
- single-{$post_type}-{slug}.php for custom post types
- Conditional for single-{post-type}.php
- 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
- Multiple Single Post templates
- Custom taxonomy query for a custom post type
- Need some templating advice for templating with custom post types and taxonomies
- Create sub single pages
- Using previous_post_link and next_post_link to wrap around post sequence
- Template tags to display custom post type posts in category template?
- custom post type archive template per custom taxonomy term
- Display posts of child category in template
- custom taxonomy – Template not working
- Create separate template for shared custom taxonomy with shared terms
- Custom template for post type not working
- Custom Post Type Templates?
- wordpress 3.4 template files in subdirectories
- Lock post meta block at the bottom of a custom post type
- How do I provide a “show all posts” link in a paginated term archive?
- 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
- How can I force custom post type to use a specific template?
- Merge multiple custom post types in a single archive template
- Trying to edit the single page from a Custom Post
- Need to display same custom post type on 2 different singles templates
- Custom post template for particular posts
- Plugin templates in which directory
- Using wordpress template tags within an array
- Include custom post type single template, but respect theme override of template if it exists
- Custom post type not using custom template
- Custom Post Type template stored in plugin folder not showing in post attributes dropdown
- Single Template that can be applied only via URL
- How to clone the “Projects” Custom Post type in Divi theme
- Create template for taxonomy results limited by Custom Post Type
- 2 Templates 1 custom post type according url
- Programmatically rewriting slug through functions.php but returns 404
- How to use custom template files in deeper directory?
- Migrating a taxonomy’s tags to the native category
- How can I get this request to use the Custom Post Type page template instead?
- Single page not working for custom post type
- Get term name without a foreach loop
- Display custom post types in wp_list_pages
- Custom posts template page
- How can I use archive-{post_type}.php theme template?
- Templates for hierarchical custom post type
- Apply template by path/slug related to custom post type?
- How to get the current category with custom posts
- Assign a template to a custom post type when displayed by the main loop on the home page
- trying to show single post but displays all post on a custom post type
- Custom Post Type Specific Post Template
- How to create a archive template for custom post type [duplicate]
- WP not recognizing custom post type / template
- Create a custom taxonomy template that loops through child categories in term order?
- My template won’t apply, theme still fallback to index.php
- One Custom Post Type two different Templates
- How to make post templates to include shortcodes only?
- On click some element i want to use some template
- Loop all post on single.php
- Post template with breadcrumb needs to show page navigated from
- Custom post type single page 404
- Accessing download link from the loop with WP Download Manager Pro
- get_the_terms child terms for current post/custom post only
- Turning archive templates to a page template maintaining the slug
- Why custom post redirecting to index page?
- custom post type single page
- custom post type single post preview for pending status
- get_permalink() of page the enclosing page not posts
- WordPress Custom Post Type – Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered
- How to Create a Default Fixed Custom Posts layout for text and images
- Why did permalinks setting affect the pages?
- How to make a custom search template for custom taxonomy?
- Custom post type with two templates
- Custom Post Type tag taxonomy “Page Not Found”
- Why isn’t my custom post type using the corresponding custom post template?
- Custom post type single display is ommited
- Single page problem when permalink type changed
- Load different template for CPT (in loop) in my plugin?
- Single Page for two custom post types
- Query child posts on parents single.php?
- Custom Post Type Template based on Taxonomy
- Template with Custom Post Type (Custom Tables) does not work
- is_singular won’t call my functions?
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Most appropriate way to display CPT’s by children terms of custom taxonomies while retaining desired permalink structure?
- how to pass args for archive.php query?
- CPT Template Option to Top
- Show my custom post id if a country or ip
- How to create custom page templates with default page layout framework?
- Can I have a specific template for products even if they are standard posts and not CPT?
- How can I produce multiple webpages with a different output based on one entry/Page/custom Page?