WordPress Register Post Type

Creating a new post type is really easy you don’t need plugins to do it.

 

Just add this post type to your theme functions.php file and that’s it. You will have Listing named a new post type.

function register_listing() {
    $args = array(
        'public'    => true,
        'label'     => 'Listing',
        'menu_icon' => 'dashicons-book',
        'has_archive' => true,
	'show_in_rest' => true,
        'supports' =>   array( 'title', 'editor', 'author', 'comments' , 'revisions' , 'custom-fields' , 'editor' )
    );
    register_post_type( 'listing', $args );
}
add_action( 'init', 'register_listing' );

This post type have ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘comments’ , ‘revisions’ , ‘custom-fields’ , ‘editor’ )

If you need to add more support to your post type

Check this link https://developer.wordpress.org/reference/functions/register_post_type/#supports

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments