The most widely used custom post type (CPT) in WordPress is probably "portfolio". Besides the usual "pages" and "posts", you can generate your own custom post types for all manner of purposes. But what is a custom post type in WordPress? How do you make one? And what are some interesting ways to use them?
What is a WordPress custom post type?
Do you want to expand your website? To give your users even more important content on your personal or business website? If so, you'll likely need more than just "pages" and "posts" in WordPress. For example, if you want to have recipes on your website, create a glossary, provide downloads, automatically list your staff or seminars - in addition to your blog news or current articles. Even a product in a webshop plugin is a custom post type. Custom post types fall into one of two different categories:
- Hierarchically ordered custom post types
- Chronologically ordered custom post types
Let's take a closer look at each of these categories below.
Hierarchically ordered custom post types
These custom post types behave like "pages". Like pages, the entries are sorted alphabetically in the dashboard. Additionally, you can add sub-entries to the main entries. As with pages, there are then also sub-pages and parent pages for these custom post types.
This kind of custom post type is suitable, for example, for a glossary, a list of stores, your guitar collection, a staff list or something along the lines of a wiki.
Chronologically ordered custom post types
You guessed it, these custom post types behave like "posts". The entries are stored and sorted in reverse chronological order with, like a blog, the newest entries always appearing first.
Classic use cases for chronological custom post types are recipes, a portfolio or events. For these, it often makes sense to create custom taxonomies as well.
The default taxonomies in WordPress are "categories" and "keywords". These help you to further categorize the content and make it searchable. You can also create such taxonomies for custom post types. For example, a taxonomy "Ingredients" for recipes, "Singer/band" for songs or "Publisher" for books.
This creates automatically generated archive pages where you can filter and display, for example, only books from a certain publisher or only recipes containing Brussels sprouts.
How can I get my own custom post type?
You can create custom post types in many different ways and the approaches therefore also vary. These include:
- A WordPress plugin that provides a custom post type
- A WordPress theme that includes a custom post type
- A plugin you can use to create a custom post type
- Include a custom post type in your own plugin
- Include a custom post type in your own theme
But how do these approaches differ? Let's dig a little deeper below.
A plugin that provides a custom post type
A prime example of this sort of plugin would be a calendar for events or appointments. Programming a calendar like this yourself is rather complicated. It has to display posts that take place in the future and you also have to create different views. Moreover, there are numerous options and variables, including displaying the event organizer, the location, time, location map, etc.
You might want to display different views, like a monthly list or a real calendar. It will soon get so complicated that you'll really not want to do it yourself! Believe me, I've tried 😀. In fact, there are thousands of plugins for recipes, books, records or the like. So it's worth looking around to see if there isn't something already out there that matches your ideas and requirements.
In many cases, you'll first encounter the "Lite" versions of plugins. Functionality can usually be expanded for a fee. An example would be a PayPal connection for your Zoom yoga lessons or a quantity/person converter for your recipe ingredients. Consider carefully whether the lite version really includes what you need. It may be wise to invest some money here if you don't want to or can't program an extension yourself.
The right WordPress plugins
What would WordPress be without Plugins? There are over 50,000 of them in the official directory. But it's like the proverbial search for a needle in a haystack to find the right ones in this jumble of extensions. This article from Torsten Landsiedel will help you choose.
Custom post type included in a theme
The portfolio function is certainly the most common one we encounter here. This is used by many photographers, designers, agencies, artists or copywriters.
I always see this way of creating custom post types as a bit problematic. The function is, of course, incredibly useful if it's exactly what you need. But what happens if you want to change your theme in three years' time? In the worst case, the custom post type you've painstakingly filled will be gone when you change your theme and you'll need to create all your entries in the portfolio again. Only experienced developers can use a programmed plugin to retrieve the entries. Even then, the archive pages will usually need to be redesigned from scratch.
I'd therefore think twice about using this theme function. Or see if you can find a plugin that does the same. This way, you can still use the plugin after you've changed your theme - and you don't need to worry about your content disappearing.
A plugin to generate your own custom post types
Yup, there are even plugins for that too. Some WordPress plugins make creating and filling custom post types really simple. So if you need something specific but can't program yourself, this is the way to go. You could generate a custom post type, for example, for a sponsor list or to map pharmacies belonging to an association. Or the members of your bowling club for that matter!
Furthermore, you can - in combination with for example Advanced Custom Fields - create the most diverse applications. How this works is described very well by Michael Hörnlimann in his article What are Advanced Custom Fields (ACF) in WordPress . This is how the backend of the Plugins Custom Post Type UI looks like:
Develop a custom post type plugin yourself
The most elegant way to create your own CPT is definitely also the hardest. Developing your own plugin for a custom post type presents you with two hurdles. For starters, "How do I program a plugin?" and then "How do I register the custom post type? Luckily, there are already loads of DIY instructions out there WordPress universe to help you. And with a little internet research, you'll usually even find exactly your own use case.
Once you understand the different setting options, you can create a custom post type completely according to your own ideas. If you're also skilled in creating templates that represent this custom post type, the possibilities are endless. In combination with Gutenberg you have the chance to make some very appealing creations.
Create a custom post type in your theme
Just so we've covered all bases: you can also create a custom post type in your theme. But I don't recommend it as your custom post type will also be gone when changing theme. Of course, you would have the know-how to add it into your new theme again but you can simply avoid this step by using a plugin instead.
In Theme you can design the views of your CPT archive and the CPT single view, if they need customizing at all. It is much more complicated to do this with Plugin . But thanks to Gutenberg you can at least customize your single views extensively. With a simple Plugin like Duplicate Post you can duplicate your entries and customize them for the new entry.
Examples of custom post types
A glossary for SEO purposes
Please don't argue with me whether creating such a collection makes sense from an SEO point of view. I actually don't know if it makes any sense or not because I'm not an SEO expert 🙂.
The original idea was to create a glossary for the different terms so that the results would appear in web searches or become even more relevant through internal links.
I implemented the request with a hierarchical custom post type for the individual terms. In addition, I programmed a list that can be accessed via the letters. It's a practical example that can be used for many applications:
Appointment calendar for a dog school
This is a classic example of a calendar showing training and workshops due to take place in the future. Interested dog owners can use the simple overview to select and book an appointment.
I have realized this with the Plugin Events Manager. This offers a large variety of possibilities - actually a bit too many for such a "simple" task. But programming it myself would have been too much work in this case.
Personal recipe collection
I recently created a chronological custom post type for myself for recipes. There are taxonomies for occasions and ingredients, the rest was created using Gutenberg. I left the view of the archive page in the design of my blog. This way nothing had to be developed extra.
There are, of course, plenty of plugins available to do this too. In this case, however, I wanted to have the recipe page exactly as I imagined it. I can see a similar approach working well for travelogues or a separate photoblog in addition to a news page.
Download area in WordPress
Here, the customer wanted a simple upload in the backend for his downloads in chronological order. The PDF upload was realized via advanced custom fields. I needed to force WordPress programmatically to get the automatic display of the first page as a screenshot. The user can also filter the downloads further via the taxonomies "Areas" and "Keywords".
My conclusion on custom post types
Custom post types give you plenty of ways to enhance your WordPress website. With the right tools, you can quickly create custom post types yourself. Important content for your users can be presented with both appealing archive pages and attractive single pages.
Automatically created archive pages enable filtering and searching of the post type. Taxonomies extend the functionality of CPTs by automatically creating these archive pages for the respective taxonomy terms. Do you have any nice examples of CPTs? Let me know in the comments! 🙂.