How to Create WordPress Custom Post Types?

Do you have any difficulties with the limited post types provided by WordPress? 

So, you are on the right page, this article will help you in creating WordPress custom post types. WordPress provides only the default post types which will not be sufficient for all content types. 

However, WordPress provides the options to create WordPress custom post types of our choice. 

So, it will be the right time to know the ways to create WordPress custom post types. 

What is the Custom Post Type in WordPress?

It is easy to explain the custom post type in WordPress because it helps in categorizing the contents. You can only categorize the content into two different types of posts and pages. 

Apart from the main two different types, WordPress has other post types like attachments, Revisions, Custom CSS, Navigation menus, and Changesets.

How to create WordPress custom post types? 

However, before creating a new WordPress custom post type, you should analyze your needs. In some situations, default post types might be enough for you to get your job done. 

Still, if you need new custom post types then you have two different ways.

  • Manual way 
  • Using Plugin

Creating a Custom Post type manually

The advantage of creating a custom post type manually is that it will not be affected by adding/removing any plugins from WordPress. 

Here, the Manual process is fully about using codes for creating the custom post types. You should familiar with the coding part else it may be hard to create. 

Just add your code to the file “functions.php”. Below is the sample code to create a custom WordPress post type manually.

function create_posttype() {

      register_post_type( ‘Songs’,

            array(

            ‘labels’ => array(

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

                ‘singular_name’ => __( ‘Songs’ )

            ),

            ‘public’ => true,

            ‘has_archive’ => true,

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

            ‘show_in_rest’ => true,

         )

    );

}

add_action( ‘init’, ‘create_posttype’ );

This code creates a new custom post type called “Songs”. The code label is to create a label as “Songs” which is defined as an array. Also, the post type will be available for public visibility and other arguments like a rewrite, show in rest, and has_archive.

This is all about creating a new custom post type using the coding part.

Creating a Custom Post type using Plugin

Using a plugin is the best way to create a new custom post type because it doesn’t require any coding knowledge. Since most of them don’t know the coding to create their own post type. So, the plugin will be the right choice for this type of user.

Here we discuss the new plugin called “Custom Post Type UI”. This plugin has the functionality of creating a new post and also Taxonomies. The steps for creating a new post through this plugin seem to be simple. 

First, visit the “Add New” plugin page and search for “Custom Post Type UI”. You will get the plugin and now click the “Install Now” button and activate the plugin. 

Now you can see the option called “CPT UI”. Just click and from the list select “Add/Edit Post Types”. 

To know the already saved post types, it could be shown under the link “Registered Types/Taxes”.

If you like to import some post types from other websites then you can use the “Tools” settings.

So, these are the screens you will have in that plugin. It looks easy to add custom post types through different types. 

That’s all about installing a custom post type using a plugin.

Conclusion

WordPress Custom post type helps in organizing your website and the post type has the power to divide the content based on the information. So, just you need small technical knowledge and plugin skills to make your website well organized. 

Leave a Comment

%d