Custom Post Type – Single-{slug}.php to override Single-{$posttype}.php in WordPress

I am looking to add a custom template for a single post inside of a Custom Post Type. The Custom Post Type is working as it should and all of the posts are correctly using single-{$posttype}.php. However, for the page with the slug “our-wedding”, I am trying to override single-{$posttype}.php and have it use single-our-wedding.php. However, the page is still using single-{$posttype}.php.

Any ideas?

Related posts

Leave a Reply

1 comment

  1. You can either use a solution that will let you assign custom templates to one particular post of that post type (there are plugins).

    Or you can edit the single-{$posttype}.php to include a

    if( is_single('our-wedding') ){
       get_template_part( 'my-template');
    } else {
       // The usual code for this single-posttype
    }
    

    And then create a file called “my-template.php” inside your theme folder.

    (Edited based on user feedback.)