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
- How come Featured Image isn’t showing up in my Custom Post Type?
- How to use a custom post type archive as front page?
- Conditional for single-{post-type}.php
- Set posts of a custom post type to be private by default?
- 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
- clients list using wordpress
- Custom taxonomy query for a custom post type
- Date archives for custom post type
- How can I add dropdown widget/box to admin post page?
- Using previous_post_link and next_post_link to wrap around post sequence
- Display posts of child category in template
- custom taxonomy – Template not working
- Create separate template for shared custom taxonomy with shared terms
- Append taxonomy terms as class names in markup?
- wordpress 3.4 template files in subdirectories
- Display only custom post type count for current author on the “At a Glance” dashboard widget
- 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
- Merge multiple custom post types in a single archive template
- GravityForm: Populate Dropdown with custom post type [closed]
- Trying to edit the single page from a Custom Post
- Custom post template for particular posts
- Custom Taxonomy Permalinks Redirection
- Add custom column in custom post type edit page
- Single Template that can be applied only via URL
- custom post type not showing in menu
- How to clone the “Projects” Custom Post type in Divi theme
- I need to add endpoint for wordpress categories
- Featured image overlay when changing post status
- Programmatically rewriting slug through functions.php but returns 404
- How to use custom template files in deeper directory?
- Hide a widget inside a div on specific type of post
- How can I get this request to use the Custom Post Type page template instead?
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Get term name without a foreach loop
- custom post for slider
- How can I use archive-{post_type}.php theme template?
- Navigate posts with different post type that are in the same categories
- Show Custom Message in WordPress Admin
- How exclude or skip post type with get_next_post_link
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Create short URL with auto 301 redirect
- Is it possible to use array_walk() to append terms to an array of posts?
- How do I assign a block template (.html) to a custom post type?
- WordPress notification if new post published
- Custom Post Type setup
- Custom Post Type homepage template
- Twitter Product Cards
- Display Posts Query with IF function
- Excerpt length: get first paragraph
- Set generic reservation form for custom post type
- Submit Custom Postypes from frontend
- One Custom Post Type two different Templates
- Need help with Custom Post Types and Taxonomies
- 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
- How to add specific terms in a custom post type?
- Limit custom post type to the authors only on front-end!
- Accessing download link from the loop with WP Download Manager Pro
- Create posts inside CPT post
- get_the_terms child terms for current post/custom post only
- custom post type single page
- custom post type single post preview for pending status
- WordPress Custom Post Type – Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered
- Populate custom post type/custom fields from an external database
- Work and Display a Custom Post Type as a normal Post
- Custom Field to post_title
- How to make a custom search template for custom taxonomy?
- Custom post type with two templates
- Post Custom & Taxonomy 404 error
- How To Display Category list from Portfolio post type plugin?
- Custom Post Type tag taxonomy “Page Not Found”
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Custom post type single display is ommited
- Load different template for CPT (in loop) in my plugin?
- Query child posts on parents single.php?
- Template with Custom Post Type (Custom Tables) does not work
- is_singular won’t call my functions?
- Allow authors to create article image
- How to create custom page templates with default page layout framework?
- Comments are not working on Custom Post Type
- Can I have a specific template for products even if they are standard posts and not CPT?
- Custom post type is_singular condtional not working when managing sidebar display
- Is it possible to use a post name in a custom post slug?