For the templates WordPress uses, please always refer to Template hierarchy scheme in the Codex.
As you can see there, single-{$posttype}-{$slug}.php
does not exist, there is only single-{$posttype}.php
.
To do what you want, have a look at the filter 'single_template'
:
add_filter( 'single_template', function( $template ) {
global $post;
if ( $post->post_type === 'event' ) {
$locate_template = locate_template( "single-event-{$post->post_name}.php" );
if ( ! empty( $locate_template ) ) {
$template = $locate_template;
}
}
return $template;
} );
After adding this in your functions.php
, you can create the file single-event-{$slug}.php
and it will be loaded by WordPress.
Related Posts:
- single-{$post_type}-{slug}.php for custom post types
- What is singular.php?
- Multiple Single Post templates
- Custom Post Type with Nested Taxonomy and Template Files
- How do I create new content pages for my Custom Post Type?
- Single page template for custom post_type
- Trying to manage templates on a blog with lots of custom taxonomies
- WordPress Template Hierarchy
- How to show the archive / post type description on Single templates
- Include custom post type single template, but respect theme override of template if it exists
- WordPress Doesn’t Generate Taxonomy Archive
- Custom Empty Results page for my Custom Post Type
- 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
- Custom Post Type homepage template
- Function to allow single post template based on custom taxonomy?
- Conflict in function to allow single post template based on category
- Templating advice sub posts of a CTP
- Assign for all post of a post type a specific single-post template
- taxonomy – templates are not loading
- Templates for CPT not working
- WordPress Custom Post Type – Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered
- Single taxonomy for different custom post types
- DIVs not showing correctly on CPT?
- Custom Homepage As Single Page or Custom Post Type?
- Can I assign a template to a custom post type?
- Custom post type single-{custom}.php not working
- Custom Post Type Plugin: Where Do I Put The Template?
- Searching multiple custom post types and pages
- CPT Template Not Showing – Getting 404
- Taxonomy, Terms, and Template Files
- Get page by template?
- Custom taxonomy query for a custom post type
- Custom Post Type Archive URL takes over page URL
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Custom Post Type Archive Template
- Clean URL permalink for custom post type
- where can I see my custom post type archive template?
- Post Rank on Single Post page based on custom field
- Archive or taxonomy pages not working for custom post type
- Custom template for post type not working
- wordpress 3.4 template files in subdirectories
- Rewrite Custom Post Type URL slug
- 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
- Custom Taxonomy term archive template
- How to call custom single post?
- Custom post template for particular posts
- Custom template page with custom archives listing by user
- Custom Post Type template stored in plugin folder not showing in post attributes dropdown
- Remove single page for custom post type
- How to clone the “Projects” Custom Post type in Divi theme
- Custom post type content using custom fields without template
- Programmatically rewriting slug through functions.php but returns 404
- How can I get this request to use the Custom Post Type page template instead?
- Archive for a Taxonomy of a Custom Post type
- Get term name without a foreach loop
- Including all post id’s of a custom post type into an array
- Set templates for custom post types
- Main query not querying any posts in custom taxonomy template
- How can I use archive-{post_type}.php theme template?
- Which file/template is in charge of taxonomies for custom post types?
- How do I assign a block template (.html) to a custom post type?
- adding custom post type “name” to single template
- Getting custom taxonomy posts on archive page
- Archive Template being used instead of Category Template for Custom Post Type
- Custom post types templates
- Set generic reservation form for custom post type
- How can I allow users to edit text that will be displayed on a custom post type archive page?
- handling templates and widgets for custom content types
- Add custom template ‘sub-page’ to Custom Post type?
- Load info from customposttype into template page
- custom post template design with dropdown option
- Custom post type single page uses the right template in preview mode but shows a different template after being posted
- Post Attribute Section missing for Custom post type
- How to assign post to category
- Custom taxonomy with custom post type template not showing
- Custom taxonomy template for custom fields loop [closed]
- Values show up in custom home page but not in custom post pages
- How to get adjacent_post custom_field value
- Single Page of Custom Post Type Not Showing the Content Of post
- Organising custom taxonomies and custom post types
- Include template if a post is a single product
- Display Taxonomy Term for CPT on single-CPT.php
- How to decouple custom post types components from template?
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- Show Templates in Custom Post Type Editor
- Parent to another Custom Post Type – Template files not being recognized
- How to avoid hardcoded text in a custom page template?
- Having some trouble properly displaying Custom Post Types in templates
- query_post while (have post) get_template_part()?
- Using custom post types within a section of a template
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Problem retrieving custom field for a custom post type
- Only One Post of Custom Post Type Appearing on Template Page
- Choose custom post type template by category
- using a template for more then 1 page
- Why isn’t page attributes dropdown not showing up in a custom post type