Template option is not shown with a custom post type
-
Not sure if I am going mad, but I can’t seem to figure out how to add the template selection with my custom post type.
With Posts and Pages, I can select a template. Now I want to do the same with my custom post type. Everything works perfectly, but I can’t seem to make this work… Or show.
This is my registration of the custom post type.
function create_posttype_courses()
{
register_post_type(
'mycustomtype',
array(
'capability_type' => 'page',
'labels' => array(
'name' => __('Custom Types'),
'singular_name' => __('Custom Type')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'mycustomtype'),
'show_in_rest' => true,
'template' => array(),
'supports' => array(
'title',
'editor',
'excerpt',
'author',
'thumbnail',
'comments',
'revisions',
'page-attributes'
),
'hierarchical' => true,
)
);
}
add_action('init', 'create_posttype_courses');Most answers I found was that you have to add the ‘page-attributes’ to the supports array, but that makes no difference.
The ‘show_in_rest’ seems to be important too, not sure why. But it has been set to true from the start.Does anyone know what I am doing wrong?
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.