6 Steps: Create Custom Post Types in WordPress – I

Custom Post Types in WordPress is the feature which makes WordPress so popular content management platform. By default Post, Page and 5 others are post types available in WordPress. A few example of Custom Post Types are Portfolio, Project, Contact Form 7 or Product in WooCommerce etc.

You might need custom or additional post types for your own need, theme or plugin. Assigning WP default or custom categories or tags, generally saying taxonomies to your CPT is also a common requirement.

Create Custom Post Types

You might wish to have a different menu and page under WordPress dashboard to manage your own custom content. For example Movies, Testimonials and Books custom content types with custom fields to input post data.

Further, there might need a different archive page to display these post types.  Exporting your taxonomies and custom post types is also a necessary step if you’re developing in a local environment.

The 6 steps article is an attempt to let you learn these process and smoothly apply within your theme starting from custom post types to exporting custom fields you have developed locally. The series of articles is divided into six parts and in this first part, we are going to setup Custom Post Type in our theme.

Create Custom Post Types in WordPress

Before we continue, let’s look what is included in all 6 steps, a series of articles:

Create custom post types

WordPress Categories and Tags taxonomies to CPT

Custom taxonomies for custom post type content

Adding custom fields to CPT

Display custom fields content in WP templates 

Exporting custom taxonomies/fields & further reading

There are few popular plugins to create additional post types along with custom taxonomies and fields for them. I have listed them at end of the article. If you are not a coding guy, you can install and setup CPT as per your own requirements.

To manually create custom post type, we need to use a function namedregister_post_type() in functions.php file of our WordPress theme. I’m going to create Book post type.

Few Notes:

You need to change the term Book, Books or book with your custom post type name. Also $td should have the name of your theme or plugin text domain. We have commented line #28 and #34 here. We will discuss these just in next tutorials of this series.

There are plenty of arguments to pass while registering post type with a default value if not supplied. Surely check all of these arguments at WordPress Documentation. If something doesn’t suit your requirement, don’t forget to assign the updated value to args array.

The menu icon can be picked from WordPress Deshicons.

Note that if you rename the post type, your posts / taxonomy / custom field / slug etc. might get disappeared. In the last post in custom post types series, I have mentions how to safely rename CPT.

Now login to WordPress dashboard and check the post type Book is listed there.

Custom Post Types Plugins

In the next part, we are going to add WP default Categories / Tags taxonomies to these post type we created. But before that below is list of free Plugins from WordPress repository. Drive with them if you prefer to create custom post types, taxonomies and fields using a plugin:

These plugins present you friendly forms in WP dashboard. There you can select or specify required names and all the supported arguments for registering custom post types, taxonomies and fields. If you have liked the post then don’t forget to share the series to let others discover.

Read next: Add WordPress Taxonomies to the CPT.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.