function create_custom_post_type() {
register_post_type(
'posttype', // post type name
// CPT Options
array(
'labels' => array(
'name' => __('Posttypes'), // title
'singular_name' => __('Posttype') // editor right sidebar title
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'posttype'),
'supports' => array(
'title',
'editor',
'thumbnail',
'page-attributes',
'revisions',
'trackbacks',
'excerpt',
'comments',
'author',
),
'capability_type' => 'post',
'taxonomies' => array('category')
)
);
}
add_action('init', 'create_custom_post_type');
function book_setup_post_type() {
$args = array(
'public' => true,
'label' => __( 'Books', 'textdomain' ),
'menu_icon' => 'dashicons-book',
);
register_post_type( 'book', $args );
}
add_action( 'init', 'book_setup_post_type' );