Home > AI > Backend > Wordpress >

register_post_type

API

register_post_type( 
    string $post_type, 
    array|string $args = array() 
)


1) $post_type(required)
2) args (optional)


$args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => $rewrite,
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false, // true is like Page, false is like Posts
    'menu_position'      => null,
    'supports'           => array('title', 
                                  'editor', 
                                  'author', 
                                  'thumbnail', 
                                  'excerpt', 
                                  'comments', 
                                  'revisions', 
                                  'trackbacks', 
                                  'page-attributes', 
                                  'custom-fields', 
                                  'post-formats')
    'show_in_rest'       => 1
);

Leave a Reply