
Have you ever heard or read about it? WordPress Custom Post Types but don’t know exactly what it is? Or you have no idea what it is about?
When you first hear the term custom post type, it might sound a bit Chinese to you. To me, new to WordPress with no experience, it sounded so advanced that I thought it wasn’t for me.
But nothing is further from the truth, since it is a very interesting option for almost anyone who needs to create a website, and the truth is that it is very easy to understand and use.
That is why I want to explain in this post everything you need to know about custom post types, from what they are to how they are used in WordPress.
What will you find here?
What is a custom post type?
A custom post type is a custom post type , as the name suggests. But since I just translated his name into Spanish, it probably stayed the same, so let’s take a closer look.
By default, when you install WordPress, it comes with only two post types: posts (also known as posts) and pages.
At first, WordPress only came with posts because the purpose of this CMS was just to create a blog . But over the years and with the tremendous growth it has had, posts have fallen short and pages have been added that serve a different purpose than posts.
And as WordPress continued to grow and usage increased with its growth, custom post types emerged.
So what is a custom post type?
Well, it is a custom post type that you can add and customize as per your needs to add content that there is no space to add in posts or pages.
Sometimes you’ll find it written under an acronym, which stands for: CPT . You know, in the 21st century, we don’t have time to waste.
Examples of custom post types
One of the clearest examples out there is when you create an Online Store with WooCommerce plugin that adds a custom “Products” post type.
Adding shop products requires a post type and will not add them to posts or pages for this CPT to be generated.
To see the content that is in the CPT of the product, a call is made from the Store page (or any other) and only the content that you have uploaded to the products is displayed.
What other examples are there?
Imagine a website for a real estate company that needs to upload different properties for sale. To do this, you can create a custom listing type called «Properties» and add it there to display later in the «Properties for Sale» section of the website.
Or an online training academy that needs to show the courses they teach. For this purpose, a custom post type would be nice to aggregate all those courses and display them on the web.
Or even a business or freelancer who hosts events may need a custom post type to add future events there.
There are thousands of examples, but I think these three should give you an idea of where the shots are going and when it makes sense to use CPT.
Custom Post Type Taxonomies
Another thing you might want to know is that custom taxonomies can be created for each custom post type .
By default, WordPress Posts comes with two taxonomies: Categories and Tags, which are used to classify the different blog posts you upload. Pages come without any taxonomy.
Well, you can create as many taxonomies as you need to classify all types of content that you have or create on your website.
Going back to the example of a real estate agency with a custom listing type called «Properties», a taxonomy called «Property Type» could be created to indicate if it is an apartment, house, duplex, etc., a taxonomy called «Agent ‘ to indicate which of the agents is responsible for handling that property, etc.
How to Create a Custom Post Type in WordPress
Now that you know the theory, let’s see how to create a custom post type in wordpress with the desired taxonomies .
Although CPTs can be created using code, the easiest way is to use a plugin created specifically for this purpose.
The one I recommend is also the most downloaded and used for this: User interface for custom post type . You can download it from the official WordPress repository .
When you install it, a new tab called «CPT UI» will appear. Click Add/Edit Post Types to add a new one.
The first thing it asks you is the snail that this CPT is going to have. As an example, let’s say I want to create a course on my website that consists of several topics. I’ll add a post type called «topics».
In this case I would put «theme» in Slug.
The next thing would be to add a plural and singular name, that is, «topics» and «theme».
These would be the three fields that you must fill in Yes or Yes to create a new CPT, but then you can customize the texts that each of the labels will have:
If you leave it as it is, it will show the default labels, these are the texts that appear on the left.
You can also change some CPT settings:
You can leave most of these settings as default. The most interesting are at the bottom, which would be the following:
menu icon : Allows you to load a custom icon or choose one from Dashicon and display your class. In this case, I’ll use the cap icon found in Dashicon, which is one of the best suited for the «Theme» custom post type I created.
support : Here you can choose what elements or properties this type of map has. By default «Title», «Publisher» and «Featured Image» are selected, these are the three things that would appear when creating a new «Theme», but you can add support for other features from the list if you wish. .
Taxonomy – This option allows you to make the new CPT compatible with the taxonomies that come standard with WordPress, i.e. categories and tags. If you browse any of these, the posts and your new CPT will share those taxonomies. I recommend not tagging it and creating your own custom post type taxonomies, which we’ll cover now.
When everything is ready, click «Add Content Type». A new tab will automatically be created with the name of the CPT and the icon you selected (if you did not specify an icon, the same tab will appear with the Inputs tab by default):
Now I can do differently Add topics that my course will have.
Create taxonomies for CPT using the custom post type UI
You’ve already created your custom post type, but you want to be able to categorize it, so you’ll need to create one or as many taxonomies as needed.
To do this, you need to go to «Add/Edit Taxonomies» in the «CPT UI» tab.
I’ll add a taxonomy called «Topic Categories» to be able to classify different topics according to their category (for example: web design, marketing…).
You need to specify the category tag, plural and singular tag, and most importantly, what type of content it should be associated with. In this case, I want this category to appear in CPT themes, so I’ll mark it:
Here you can also customize the label texts if you want and adjust some options when creating the taxonomy. I will recommend you to change one of the existing options, which is to set the «Hierarchical» option to «True».
That way it will look the same as the input categories. If left false, it will be displayed as a post tag.
Once added, it will appear on the CPT tab and also on the CPT edit page where you can add as many terms as you like:
How to display custom post types on the web
Once you’ve added the custom post types you need, with their categories (or not), and created different pieces of content, there’s only one thing left to do: display them on the web.
There are several plugins you can use to display the type of content you want. If your site uses ElementorPro, you can use the Posts widget and choose a custom post type to display in the Query tab.
But if you’re not using Elementor Pro (yes, it has to be the paid version), there are other plugins that can help you display the types of posts you want.
Some of the ones I usually use are Show WP posts or Gutenberg post blocks if you use Gutenberg, both very useful and good.
Conclusion on CPT
Yes, now you know what they are, what they are for and how custom post types are used. . As you get the hang of them, you’ll find them really useful for many projects.
It’s the best way to separate unrelated content types because you can have as many as you need on the same web page.
In the next post I will explain how to add custom fields to each type of content on your website, so stay tuned 😉