• Resolved Pablostevens71

    (@pablostevens71)


    I’ve figured out how to create a custom post template for a custom post type “jobs” I created. However I want to default the “jobs” template to the “jobs” post type. I’ve tried creating a single-jobs.html in the templates directory. Didn’t seem to work. Am I missing something? I can’t find any info on how to do this, like it was possible by creating a single-jobs.php in previous versions of WordPress without the block editor.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Pablostevens71

    (@pablostevens71)

    Think I just solved my own problem. If you add single-jobs.html to the templates folder and cut and paste the block HTML into it, it does actually work. However in Twenty Twenty Two in the post type editor in the dropdown it still says “default”, there is an option for the Jobs template too. I guess “default” is the one I specified by creating the named post template file. Long story short, it works, just the UI is a bit confusing.

    Moderator Kathryn Presner

    (@zoonini)

    Hey there! I don’t think Custom Post Type templates are officially supported in the Site Editor yet. Once they do, you should be able to add them within the Site Editor instead of externally, and hopefully the UI will be clearer.

    Glad you found a workaround for now, though!

    One heads-up: if you’re adding new templates by creating files and putting them inside in the “templates” directory manually – be careful the next time there’s a Twenty Twenty-Two update. If you update the original theme, you’ll lose your manually created templates, as the templates folder will be overwritten during the update process. (I just tested this myself now to be sure.)

    To avoid your manually created templates from being overwritten, you could create a child theme. There’s a child-theme option in the Create Block Theme plugin to help with that.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom Post Templates’ is closed to new replies.