I think what you’re looking for is the WordPress Template Hierarchy. Basically you can just name the template single-{custom-post-slug}.php
and put it in the right directory.
Update
Now that I understand what you’re actually asking: I bet you could hook {$type}_template
, which is called by get_query_template()
. It’s expecting a path to the template which has been loaded. You can filter based on get_queried_object()
so that the correct template is used in the correct place. It’s probably gonna take a bit of tinkering and a lot of print_r()
ing on your part, but I think it’s doable.
Related Posts:
- Conflict in function to allow single post template based on category
- Template for specific post of custom post type
- How do I create new content pages for my Custom Post Type?
- Custom post type loops with different page templates
- How to show the archive / post type description on Single templates
- How do I find a way to create a global single.php for a custom post type?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Template code to split a post and print a custom field?
- How to assign post to category
- Assign for all post of a post type a specific single-post template
- DIVs not showing correctly on CPT?
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Custom Post Type with Templates using Meta Boxes?
- Can I list a custom post type within another custom post type in the admin area?
- Change custom post type slug from plugin options
- Query with no terms uses index.php template instead of archive.php
- Custom post type not displaying content from single-{custom post type} page
- Create template for taxonomy results limited by Custom Post Type
- Can’t edit custom post type
- Template for custom post with custom taxonomy
- WordPress Custom Post Type Children Template
- custom post type parsed as attachment
- Getting template_include to work when allow_url_include is off?
- Custom post type content using custom fields without template
- Set URL link to featured image of custom post type
- Change CPT archive title
- AJAX load more for different custom post type loops
- PHP variable not regenerating when publishing multiple posts at the same time
- 2 Templates 1 custom post type according url
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- Single template showing all posts of that type
- How to target a specific custom post type post and its all children and grandchildren?
- Featured image overlay when changing post status
- get_post_meta not working on publishing
- Custom taxonomy and custom post type – wrong permalinks and template
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Display featured image from one CPT within another CPT query
- Query taxonomy of taxonomy of custom post type
- Best way to style first post differently?
- Can I override a CPT template on a per post basis with Gutenberg block editor?
- How to make custom posts types display when published for the future
- How to rewrite url for any specific taxonomy?
- Programmatically rewriting slug through functions.php but returns 404
- create a new page from a custom post type similar to an authors page
- CPT archive admin menu label
- Anon function and add_meta_box
- Content vs Template on custom post
- How to use custom template files in deeper directory?
- Hide a widget inside a div on specific type of post
- WordPress Doesn’t Generate Taxonomy Archive
- Shortcode not working with post counter
- A case for Hierarchical Custom Posts
- Changing default ‘posts’ parameters with register_post_type_args
- How to display single post from custom post type loop?
- Setup template_redirect using has_term when NO term assigned
- Custom taxonomy returns 404
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Cannot save CPT meta box
- Filter widget outputs
- Adding Page Templates to post but it ignored it
- Allow users to create posts without logging in?
- Template for all categories of a custom post type?
- How to change permalink to include custom post type
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Migrating a taxonomy’s tags to the native category
- Add term to custom post type on draft
- Flush Rewrite Rules when new site is created on network
- How to assign classes to all elements?
- next_/previous_post_link() `in_same_category` appears to fail when true
- Want to be able to sign up subscribers as authors
- WordPress custom taxonomy template not working
- How can I get this request to use the Custom Post Type page template instead?
- Load scripts based on post type
- Different Category system needed for the Custom Post Type
- Not Able To Render Single-CustomPostType.php File
- How to specify a template for a path like http://example.com/something?
- Custom templates for a specific category
- Archive for a Taxonomy of a Custom Post type
- Global custom meta box
- Template not working for the custom Post type
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Single page not working for custom post type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- categories should be available across all custom post types
- Custom post type pages return 404 page?
- single-{post_type}.php not working
- Warning: Invalid argument supplied for foreach() in post.php [closed]
- Get term name without a foreach loop
- Featured Image field not appearing in Custom post type
- Cant get paginations on single.php to work with my custom post types
- WordPress 3.9 not using custom template
- Including all post id’s of a custom post type into an array
- Template files for Custom Post Type and Taxonomy
- Set templates for custom post types
- How to Create Template File for Parent Page of Custom Post Type