The solution shared in this answer on StackOverflow works for me:
function get_book_post_type_template($single_template) {
global $post;
if ($post->post_type == 'books') {
$single_template = dirname( __FILE__ ) . '/themefiles/single-books.php';
}
return $single_template;
}
add_filter( "single_template", "get_book_post_type_template" ) ;
Related Posts:
- single-{$post_type}-{slug}.php for custom post types
- 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?
- Assign single template to multiple custom post types?
- Add Content to Page without shortcodes
- Multiple Single Post templates
- How to set a fall back template for a custom post type in a plugin?
- Custom taxonomy query for a custom post type
- How to list/show all custom post types regardless of category?
- Need some templating advice for templating with custom post types and taxonomies
- Custom Post Type with Nested Taxonomy and Template Files
- Template tags to display custom post type posts in category template?
- How do I create new content pages for my Custom Post Type?
- custom post type archive template per custom taxonomy term
- Custom post type loops with different page templates
- Display posts of child category in template
- custom taxonomy – Template not working
- Include different loop templates in search query
- Create separate template for shared custom taxonomy with shared terms
- Custom Post Type Templates?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- 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?
- How can I force custom post type to use a specific template?
- Multiple templates for a custom post type
- 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
- Query with no terms uses index.php template instead of archive.php
- Create template for taxonomy results limited by Custom Post Type
- WordPress Custom Post Type Children Template
- Getting template_include to work when allow_url_include is off?
- 2 Templates 1 custom post type according url
- Filter widget outputs
- Migrating a taxonomy’s tags to the native category
- How to specify a template for a path like http://example.com/something?
- Custom templates for a specific category
- WordPress 3.9 not using custom template
- How to Create Template File for Parent Page of Custom Post Type
- Custom post_type search pages
- how to remove pages loading with the archive templates
- Custom posts template page
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- Add Previous/Next Buttons to CPT Single Pages Only
- Custom post types with categories in template
- Creating separate feeds for custom post types
- How to get_term_meta on single custom post?
- How do I find a way to create a global single.php for a custom post type?
- Templates for hierarchical custom post type
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Apply template by path/slug related to custom post type?
- assign different templates to custom post type with homepage loop
- 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
- How to create a archive template for custom post type [duplicate]
- WP not recognizing custom post type / template
- Custom post type draft use wrong 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
- Calling a div and content in php?
- Tag template not returning posts [closed]
- One Custom Post Type two different Templates
- Conflict in function to allow single post template based on category
- How to make post templates to include shortcodes only?
- On click some element i want to use some template
- A certain theme is forcing it’s singular post layout
- Post template with breadcrumb needs to show page navigated from
- Custom Post Taxonomy Template Not Loading Properly
- Accessing download link from the loop with WP Download Manager Pro
- Turning archive templates to a page template maintaining the slug
- Templating advice sub posts of a CTP
- get_permalink() of page the enclosing page not posts
- How to override post-new.php with custom template
- 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
- Can I organise my custom post types by page?
- Why did permalinks setting affect the pages?
- I want to create an archive and single page for a custom taxonomy for a custom post type
- How to make a custom search template for custom taxonomy?
- Custom post type with two templates
- Custom Post Type tag taxonomy “Page Not Found”
- DIVs not showing correctly on CPT?
- Why isn’t my custom post type using the corresponding custom post template?
- custom post type plugin – single template
- Load different template for CPT (in loop) in my plugin?
- Search page for custom post type
- Custom Post Type Template based on Taxonomy
- Template with Custom Post Type (Custom Tables) does not work
- 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?
- Navigation links to posts in current term shortcode
- How to make a template for a specific post of a custom post type?
- CPT Template Option to Top
- WP_Query is getting the post but the_post() not rendering any Post
- Show my custom post id if a country or ip
- How to create custom page templates with default page layout framework?
- Custom post type is_singular condtional not working when managing sidebar display
- Why isn’t page attributes dropdown not showing up in a custom post type