Create Custom post type in WordPress

We have to add below code in function.php file
You can change you custom post type with services

// Own custom post type function 

function create_posttype() {
      register_post_type( 'services',
        array(
                'labels'=> array(
           'name'=> __('services'),
                      'singular_name'=>__('service')
                  ),
                   'public'=> true,
                   'has_archive'=> true,
                   'rewrite'=> array(
                            'slug'=> 'services'
                     ),
                    'show_in_rest'=> true,
             )
       );
} 
add_action( 'init', 'create_posttype');

Leave a Reply