WordPress is an awesome Content Management System where we can do amazing things even having fewer development skills. WordPress comes with default post type and we are calling it The ‘post’. Using it we can create a simple blogging website in small time. Now WordPress is going popular Content Management System and developers are developing many types of websites in WordPress.

In the non-blogging WordPress website, sometimes we need a custom post type that is required as per requirement. To create any custom post type, we can create them by plugin or without a plugin.  Now I’m going to describe here “How to create a custom post without using any plugin”.

Step 1: Place the below code in functions.php file.

Simply copy the below code and place it into the theme’s function.php file. If you are using a premium theme then use functions.php from the child theme.

Read More: How to Create a Child Theme in WordPress

function custom_post_type() {
    $labels = array(
        'name'                => _x( 'Services', 'Post Type General Name', 'unityblogger' ),
        'singular_name'       => _x( 'Service', 'Post Type Singular Name', 'unityblogger' ),
        'menu_name'           => __( 'Services', 'unityblogger' ),
        'parent_item_colon'   => __( 'Parent Service', 'unityblogger' ),
        'all_items'           => __( 'All Services', 'unityblogger' ),
        'view_item'           => __( 'View Service', 'unityblogger' ),
        'add_new_item'        => __( 'Add New Service', 'unityblogger' ),
        'add_new'             => __( 'Add New', 'unityblogger' ),
        'edit_item'           => __( 'Edit Service', 'unityblogger' ),
        'update_item'         => __( 'Update Service', 'unityblogger' ),
        'search_items'        => __( 'Search Service', 'unityblogger' ),
        'not_found'           => __( 'Not Found', 'unityblogger' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'unityblogger' ),
// Set other options for Custom Post Type
    $args = array(
        'label'               => __( 'services', 'unityblogger' ),
        'description'         => __( 'Service ', 'unityblogger' ),
        'labels'              => $labels,
       'supports'          => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
    // Registering your Custom Post Type
      register_post_type( 'services', $args );
/* Hook into the 'init' action so that the function
* Containing our post type registration is not
* unnecessarily executed.

add_action( 'init', 'custom_post_type', 0 );

Step 2: Change Setting

I want to create services custom post. please change it with your custom post name. Please update the setting in $args  > supports as per your requirements. I need ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’, ‘comments’, ‘custom-fields’ so I have added them.