Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

register_post_type wordpress

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');
 
PREVIOUS NEXT
Tagged: #wordpress
ADD COMMENT
Topic
Name
1+5 =