Adding custom post types to WordPress is a great way to add custom features in a safe way. For example, you could add estimated reading time to a custom post type without affecting the default post type. In this article, we’re going to introduce you to WordPress custom post types and show you how you can make your own. First, we’ll discuss what a custom post type is, and then we will use a plugin to create one.
What are Custom Post Types?
By default, your WordPress site has three post types:
- Pages
- Posts
- Media
At the core level, all of the above are considered “posts”, but they each behave differently. WordPress uses templates in the theme to display these types of content differently. That’s why they’re known as post types.
For example, most themes will display a comment form on the Posts post type but not on the Pages or Media post types.
Custom post types are user-created post types that can be totally unique to your site. For example, you could create custom post types for books, movies, or a diary, without affecting your regular Posts or Pages post types.
You can create as many custom post types as you want. But, in this case, less is more. Having too many custom post types can make your site difficult to use.
How to Create Custom Post Types
In this guide, we’re going to be using the Custom Post Type UI plugin to create our custom post types.
Here are the basic steps:
- Hover over CPT UI
- Click Add/Edit Post Types
- Fill in the fields
- Click Add Post Type at the bottom
Once you have installed Custom Post Type UI, you will see a button labeled CPT UI appear in the left panel of your WordPress Dashboard. Hover over this button to reveal the menu and click Add/Edit Post Types.
From there, you will be redirected to the main Add/Edit page. Under the first tab, you will fill in many fields to make your post type. These may seem overwhelming at first, but they’re mostly just labels for the WordPress user interface. These will make it easier for you (and any other users) to create content with your post type.
Start with the basic settings and work your way down through the labels. Each field comes with an explanation and example content—where appropriate.
Once you have filled in the fields, be sure to scroll down and click Add Post Type.
Some Important Settings
There are so many settings for your custom post type that you may feel overwhelmed. In this table, we’ll share some of the most important features you should use right away.
Name | Setting |
---|---|
Post Type Slug | Similar to the permalink, the slug appears in the URL structure for this post type |
Has Archive | If true, your post slug will be used to display an archive of posts for this post type |
Menu Icon | A unique icon selection will help distinguish your custom post type from the others, or you can use the default. Pick out any icon from the WordPress dashicons, or upload your own 20px by 20px image. |
How to Use a Dashicon for a Menu Icon
All of the items in your WordPress admin menu (on the left side of the Dashboard) have a custom icon next to their name. You can assign one of these to your custom post type by copying and pasting the Dashicon class name in the CPT UI field labeled Menu Icon.
You can find the dashicon class name listed to the right of the icon on WordPress.org.
Examples of Dashicons:
- dashicons-admin-site
- dashicons-admin-appearance
- dashicons-editor-help
Paste one of the above class names into the Menu Icon field in the CPT UI settings, and you will notice, when saved, your custom post type will have a custom Menu Icon.
Note: You can also use a custom image, but you are advised to keep the dimensions to 20px by 20px or fewer.
Your Post Type is Ready
You can now write new posts with your custom post type! If you have any questions or comments about this procedure be sure to leave us a comment below. We always appreciate the feedback.