Template for specific post of custom post type

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)