How to Create Custom Post Types in WordPress?


Are you curious to create custom post types in WordPress?

WordPress is mainly recognized as a blogging platform. But there are many more things that can be done using WordPress, creating custom post types is among them. Custom post types help to build all kinds of complex websites making WordPress a complete Content Management System (CMS).

In the tutorial, we have mentioned the two easiest ways to create custom code. We will cover up creating custom codes via plugins and through manual setup in the admin area. Without delay let’s start:

What is Custom Post Type?

Initially, you should know the meaning of the custom posts in order to create them in your WordPress. Custom post types are like posts and pages. By default WordPress contains the following post types:

  • Post
  • Page
  • Attachment
  • Revision
  •  Navigation Menu 

 If you wish to create a post that is different from the above you can add your own post type. Say if you own a website about newly published books you would definitely seek the post published book post type. 

This post type not only has different custom fields but also has its own different custom category structure. Major examples of custom post types are Portfolio, Testimonials, etc. Here, are the two different methods to create custom posts types:

1. Using a Plugin

The use of plugins falls under the easiest way to work in WordPress.This method is highly recommended for beginners as it is simple and safe. Follow the steps mentioned below:

  • After activation, you will see a new menu CPT UI in the admin menu. Navigate to CPT UI >> Add New.
  • Firstly, give a slug for your custom post type which will be used in the URL. Secondly, add plural and singular names for your post. Additionally, you can click on the link “Populate additional labels based on chosen labels” to fill automatically fill the rest of the label fields.
  • Scroll to the section “Additional labels” where you can provide the description of your post type and change the label as well. 
  • Now you will get a setting option where you need to set up different attributes for the custom post type. 
  • Beneath the general settings, you are allowed to check the features option that your post type will support. 
  • Make sure you click on the “Add Post Type” button to save your changes.
  • Hence, you have successfully created your custom post type with the help of the plugin. 

2. Manually Creating a Custom Post Type

If you are searching for permanent custom post types this method is for you. As the use of plugin was a safe and simple method, the demerit of the plugin is the custom post type will disappear after deactivating plugins. 

This method consists of codding. All you need to do is add the required code to your functions.php file or in a site-specific plugin. If this is your first time do visit our tutorial “How to Easily Add Custom Code in WordPress?”.

Head to Appearance >> Theme Editor. Copy the code mentioned below :

// Our custom post type function

function create_posttype() {

    register_post_type( ‘books’,

    // CPT Options


            ‘labels’ => array(

                ‘name’ => __( ‘Books’ ),

                ‘singular_name’ => __( ‘Book’ )


            ‘public’ => true,

            ‘has_archive’ => true,

            ‘rewrite’ => array(‘slug’ => ‘books’),

            ‘show_in_rest’ => true,




// Hooking up our function to theme setup

add_action( ‘init’, ‘create_posttype’ );

Don’t forget to “Update” or “Save” the changes. The above-mentioned code will add a custom post type “books” with an array of an argument. However, these arguments are the options of custom post types. Here is the final result of the code:

Thus, you have successfully added custom code with the help of code.

Wrapping up

We ensure that this guide helped you to create custom post types in WordPress. If you have any queries or confusions do let us know in the comment section below. Also, check out our other article “How to Add Custom Post Types to Your Main WordPress RSS Feed?” for detailed information about custom post types in WordPress. 


Please enter your comment!
Please enter your name here