What Are Custom Post Types in WordPress and How to Make Them
WordPress has long become more than just a simple blogging platform. Over the years, it has grown to become a bona fide Content Management System, with a vast array of options allowing for great flexibility and scalability. Custom post types are among those possibilities, and today we’re going to explain what they are, what they can be used for and how to use them.
What Are WordPress Custom Post Types
When thinking about WordPress posts, most people think of blog posts or articles, image galleries, video and audio posts. All these, plus quote and link posts, are actually formats of just one post type that comes with WordPress by default – the “actual,” regular posts.
There are five default post types in WordPress:
The official WordPress support site has a detailed explanation for each of these default types, but right now we want to focus on custom post types, i.e. those post types that do not fall into any of these categories and which you have to make by yourself, if you need them.
When it comes to blogging, the default WordPress content types are usually enough. But since WordPress started to power all sorts of websites, a need for new post types has emerged.
For instance, if you’re running a portfolio website, you may need a Portfolio custom post type. Businesses and companies need Testimonials, online shops need Products, real estate websites need Property post types, and so on.
Now, depending on your theme, these custom posts may already come out of the box. For instance, your listing WordPress theme will most likely include Listing items, and these are actually custom post types, created by the theme developer.
When to Use Custom Post Types in WordPress
In theory, you can always just use a default WordPress post type – a “regular” post or a page – to publish your content and organize it using tags and categories. But this is not always convenient, especially for niche-related custom content types mentioned above (portfolio items, properties, etc.), or at least it’s not always a great idea.
For instance, there are situations when you want to publish something using the default post types but they just don’t seem to fit your content right. This is the case with coupons, for example. Or, you may find it difficult to classify and organize the post in question using default WordPress taxonomies (that’s why there are custom taxonomies as well, but we’ll get to that in a bit). Also, there are post types that cannot and should not be displayed chronologically, in your blog roll.
Let’s take an online entertainment magazine. A large portion of the magazine’s content output consists of news. For these, the magazine will most likely use regular WordPress posts. But the magazine also has a section where they review new albums, movies, restaurants, and so on. These can, theoretically, be published as “plain” posts, but in order to add extra features to them (star rating system, search by author, etc), the magazine will most likely have to create a custom post type for reviews.
In simple words – not all post types fall into one of the default categories. And that’s precisely when you need custom post types.
How to Make a Custom Post Type
WordPress allows creating and adding as many custom post types as one might possibly want or need. These post types can be added using a simple register_post_type() function added to your WordPress theme’s function.php file.
If these terms mean nothing to you (as they don’t to most WordPress users), don’t worry. There is a far simpler way to create a custom post type and publish it on your WordPress website – using a plugin.
Custom Post Types UI Plugin
The Custom Post Types UI (CPT UI) plugin is by far the most popular plugin for creating your own custom post types. It is free and can be used even by those who don’t know much about coding or advanced WordPress customization.
This plugin allows you to use WordPress interface to register and manage custom post types, and it also helps you create custom taxonomies. This part is particularly important since your website might need additional taxonomies for your posts, not just categories and tags. For example, if you’re running a book website, you can add custom taxonomies for sorting the content by author, by genre, by location, and so on.
To install and use the plugin, just follow these simple steps:
1. After downloading and installing the plugin, you will notice a new option in your WordPress Admin Dashboard, called CPT UI. To add a new post type, simply click on Add/Edit Post Type.
2. Under the Add New Post Type tab, assign a slug to your post type and plural and singular labels.
For example, if your post type is going to be a review, the slug should say “reviews,” the plural label should be “Reviews” and the singular label will be “Review.” Make sure the latter two are capitalized. When you’re done, click on Add Post Type.
Your brand new post type will now appear as a separate option in your Dashboard menu.
3. Below the Basic settings, you will see a number of fields for entering Additional labels.
You can fill these in to change the names of default WordPress fields for post management and publishing – basically create custom fields – or you can leave them at default.
4. The section below contains more custom post type settings.
Here, you can set everything from visibility and searchability of your custom post type, to menu position, supported post type options and taxonomies.
5. You can always edit your custom post types later on, by clicking on the Edit Post Types tab and selecting the post type you want to edit or delete.
6. The View Post Types tab allows you to see details for all the custom post types you have registered.
7. Finally, you can use the Import/Export Post Types tab (or the CPT UI > Tools option in the menu) to migrate (import or export) your registered custom post types.
And that’s all there is to it.
If you’re interested in improving the WordPress taxonomies on your website, note that the CPT UI plugin also allows you to create custom taxonomies, regardless of whether you’re using custom post types or not. Just go to CPT UI > Add/Edit Taxonomies.
The steps are rather straightforward and intuitive, just like creating custom post types.
If your website needs custom post types of any sort (reviews, recipes, products, coupons, glossaries, properties, listings…) and your theme doesn’t offer them out of the box, the CPT UI plugin is your best bet. It is a simple, streamlined solution for creating custom content that can greatly enhance your website’s structure, organization and, consequently, your visitors’ user experience.