Custom post types are one of the more useful features in WordPress. Especially if you’re looking for a way to extend your favorite blogging platform into a fully-fledged content management system.
By default, WordPress provides you with a handful of built-in content types. The most commonly known ones are posts and pages. Under the hood, they behave quite the same, but they give you the opportunity to organize the content of your site in a more reader-friendly manner.
In the most classic of examples:
- you can use pages to display the content that rarely changes and remains evergreen (such as About page or Contact page),
- and then use posts to publish entries that might have an expiration date on them (like company news and blog posts).
But what if you need more? What if you want to publish other content that’s neither a page, nor a post? That’s where custom post types in WordPress come into play.
What are custom post types?
Like I said earlier, WordPress provides you with a handful of content types by default. They are: posts, pages, attachments, revisions, and navigation menus. Those last three are something we don’t need to discuss right now. They serve their purpose quietly in the background of WordPress, and they don’t require much attention on our part.
Posts and pages is where the party takes place!
From a technical point of view, they work very much alike, and the main difference between them is that posts can be accessed from your wp-admin through the Posts menu, while pages can be accessed through Pages.
These two were the classic content types available in WordPress until version 3.0 came along. In it, users were given a possibility to create their own content types, above the standard posts and pages.
Such a new content type – defined by you – will appear in the wp-admin right below the Posts and Pages menus in the sidebar. And, most importantly, you will be able to work with that new content type just like you would with posts and pages.
So the question is:
Why / when would you need to use custom post types?
Custom post types can help you in many situations, based on the type of content you want to publish on your WordPress site.
Most commonly, a new custom post type is a good idea when you simply want to start publishing something (a type of content) that needs to be kept apart from posts and pages. In other words, you want to present that something neither as posts, nor as pages.
Let me just give you a quick example:
If you run a book review site then you can probably use a custom post type called books.
Having separate section for books on your review site is going to make the content more digestible for your audience, and distinguish those reviews from the rest of your content. Additionally, this will also enable you to set specific parameters for each book – such as author or genre – and display it alongside the review.
How to create a new custom post type in WordPress
Okay, let’s get to the how-to. There are two main methods to create custom post types in WordPress:
- a) the manual method,
- b) the simplified method.
The one we’re going to cover in this guide is the latter – the simplified method. In short, it gives you the same result as the manual method, but it requires no coding skills from you at all.
The simplified method of creating custom post types in WordPress
We’re going to use a certain plugin for this. It’s called Easy Content Types.
Like with most plugins, to get it running, all you need to do is download the archive from this page, and then upload it through Plugins / Add New in your wp-admin:
After activating the plugin, you can go straight to Content Types / Post Types, and start using the plugin:
What you see here is the main configuration page of your new custom post type – the one you want to have created.
Every field is very well described, so you shouldn’t have any trouble setting things up. Just as an example, here are my inputs:
- Post Type Name: book.
- Singular Label: Book.
- Plural Label: Books.
- Everything else left to default values.
After clicking the Add Post Type button at the bottom, I’m all done!
Here’s my new custom post type:
It’s also visible in the left menu, right below Posts:
At this stage, I can go to Books, and create a new one, just like I would create a new post:
Let’s add an example book and see how this plays out:
All I did here was add some basic book details, such as title, some quick description, a featured image (the cover), and click Publish.
My book is now visible in the Books section, and I can also see it in all its glory by clicking the View link:
Here’s what it looks like on the site (my example setup uses the Twenty Fifteen theme):
Quite nice, isn’t it?
It takes care of all the heavy lifting for you.
In the background, it quietly creates all the required template files, adjusts all the function settings, and a couple of other things that make this possible.
But there’s more:
Setting taxonomies – how and why
Taxonomies are WordPress’ fancy name for things like categories and tags. In other words, categories and tags are taxonomies.
However, the standard categories and tags in WordPress relate to posts, and not to your new custom post types. Therefore, it might be a good idea to create new taxonomies just for those custom content types.
In a possible usage scenario, this can let you categorize your books. You can put some books in fiction, and others in non-fiction, for example, Or whatever else you want to do.
To set this, go to Content Types / Taxonomies:
What you’ll see is another settings panel with each option very well described. The minimum you have to fill out are:
- Taxonomy Name. I’m calling mine genre.
- Object. I’m going to select “book” since this taxonomy relates to my new custom post type – books.
- Singular Label – Genre.
- Plural Label – Genres.
- Everything else left to default values.
After clicking Add Taxonomy at the bottom, you’re all done.
Meta boxes – adding parameters to your custom content types
Now, our books look all fine and dandy, but let’s make them look even better! For that, let’s use the meta box feature in Easy Content Types and add a box called “Rating.”
Let’s go to Content Types / Meta Boxes:
The setup is very simple here as well. All I’m going to do is set my Metabox Name to “Rating”, my Page(s) to “Books”, and the Context to “side”. Like so:
Next, let’s edit the fields associated with this new meta box:
This is where we can set the individual fields that we want to have displayed in the Rating box. For me, just a field called Rating will do:
At this point, I get two things:
- I can add my rating to every book. Like so:
- I can display that rating to my readers through a simple shortcode. Easy Content Types gives you the shortcode as soon as you add a new field to your meta box:
In the end, custom post types are a great way to add new content types to your WordPress site.
You can use those content types for any purpose you wish, and whenever you find yourself in a situation that calls for more content types than just posts and pages.
For instance, like I did here, you can start publishing book reviews, product infos, movie ratings, or whatever else you find interesting. That’s the whole point – using WordPress in a way that suits your individual needs.