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?
- How to disable the single view for a custom post type?
- Can I assign a template to a custom post type?
- Get custom post_type’s archive URL
- Custom post type single page returns 404 error
- Custom post type single-{custom}.php not working
- Conditional for single-{post-type}.php
- Custom Post Type Plugin: Where Do I Put The Template?
- Searching multiple custom post types and pages
- display different template based on post type
- CPT Template Not Showing – Getting 404
- Taxonomy, Terms, and Template Files
- previous_post_link() and next_post_link() with a custom post type?
- 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?
- Setting a custom sub-path for blog without using pages?
- Custom Post Types 404 Issue
- How to add custom content template part for a custom post type on main query using a plugin
- Assign single template to multiple custom post types?
- Add Content to Page without shortcodes
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Single custom post type page redirecting to 404 page
- Loading custom page template via plugin
- How to set a fall back template for a custom post type in a plugin?
- Templates for Custom Post Types and Custom Taxonomies
- Using Templates with Custom Post Type UI
- Get page by template?
- Display Editable Text Above CPT Archive Listings
- Pre get posts for single post
- Custom taxonomy query for a custom post type
- Apply template to custom post type
- Page is defaulting to archive page and not designated template
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- is_singular() not working if called via callback function of admin-ajax.php
- How to quickly switch custom post type singular template?
- Disable Single Post View for Specific Taxonomy on Custom Post Type
- How to list/show all custom post types regardless of category?
- Custom Post Type Archive URL takes over page URL
- Need some templating advice for templating with custom post types and taxonomies
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- How to query custom posts using a dynamic category
- Using Custom Templates for Custom Post Types for the Genesis Theme Framework?
- Custom Post Type Archive Template
- Custom templates for posts like for pages: page-{id} vs single-{id}
- How to get a list of term names of the custom post type im currently on in single.php
- Posts in Multiple Columns and Rows with one single loop
- is_singular won’t call my functions?
- Create sub single pages
- Using previous_post_link and next_post_link to wrap around post sequence
- Create Pages from Database
- Custom page type – template under page attributes?
- Template tags to display custom post type posts in category template?
- Display different gutenberg template from selected post attributes
- Clean URL permalink for custom post type
- custom post type archive template per custom taxonomy term
- where can I see my custom post type archive template?
- Custom post type loops with different page templates
- Display “Post 2 of 4” on single post page?
- posts_nav_link on single post template
- Display posts of child category in template
- custom taxonomy – Template not working
- Post Rank on Single Post page based on custom field
- Disable single pages and archives and keep preview
- Archive or taxonomy pages not working for custom post type
- Include different loop templates in search query
- Create separate template for shared custom taxonomy with shared terms
- Displaying Meta Box Image
- Custom template for post type not working
- Make custom post type display as a page
- Custom Post Type Templates?
- Turn query string to sub page
- Remove header and footer but KEEP all css and js etc for a custom post template?
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- wordpress 3.4 template files in subdirectories