How to add page attribute “Template” to custom post

Since WordPress version 4.7 Post-Type-Templates are enabled in the WordPress core.

You dont need to specify the templates in the register_post_type function.
Instead, just create your post-templates like you would do with your normal page-templates.

So for example, duplicate the single.php file, rename it and add the following code to the top of the file:

<?php
/*
Template Name: My Post Template Name 
Template Post Type: post, region 
*/

After that, you should see a Post Attributes box in the backend, in this case on the post-types “post” and “region”, where you can select your template.

You can find some more info here https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/

You can also read about normal (old) page-templates in WordPress here.

I hope this is what you are looking for.

Leave a Comment