I register a custom post type with this code:
register_post_type( 'gallerydoc', array(
'labels' => array(
'name' => __( 'Gallery Docs' ),
'singular_name' => __( 'Gallery Doc' )
),
'public' => true,
'publicly_queryable' => false,
// '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
// '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
'capability_type' => 'page',
'map_meta_cap' => true,
'menu_position' => 20,
'hierarchical' => true,
'rewrite' => false,
'query_var' => false,
'delete_with_user' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
'show_in_rest' => true,
'rest_base' => 'pages',
'rest_controller_class' => 'WP_REST_Posts_Controller',
) );
I copied the code from functions.php
where page type is registered.
The only thing I commented away was the rows that says "internal use only. don't use".
But the custom type still doesn't behave like the page or post types.
The custom post type:
- cannot edit the permalink
- doesn't have a slug directly under the site root
- doesn't have a select for Template Page
I read that a custom post type cannot have their slugs directly under the root:
Wordpress - Page and custom post type with this same slug
Because that would conflict with pages and posts. But hey, pages and posts cope just fine with each other.
So why cannot my custom post type also do that?