Creating a new custom post type in WordPress can be made in a few ways.
Because using a PHP function may look complicated for non-techies, it will be easier to use a plugin.
In this article, you’ll learn how to simply create custom post types in WordPress by using the Custom Post Type UI plugin.
Pros and Cons of the Plugin
Even tho that it’s possible to create a custom post type in WordPress without a plugin, a process like so requires the user to know an advanced PHP code to accomplish that.
When using the CPT-UI plugin, we can achieve that with only a few clicks, and therefore, it will save us a lot of time.
In addition, it’s saving us from editing WordPress core files like the functions.php file that every small mistake can prevent the website from loading up.
The only con for using the plugin to create a custom post type is that it must stay active to add new items or even access the created items URL (however, there is a way around it and I will show you how).
The bottom line, it is one of the best WordPress plugins for custom posts.
How to Use the Custom Post Type UI (CPT UI) Plugin
We can use the plugin to create:
- Custom post types.
- Custom taxonomies (categories and tags).
The process to create any of them is very similar.
Step #1: Download the plugin
Navigate to the Plugin -> Add New screen of your WordPress website, search and install the Custom Posts Type UI plugin.
After activating the plugin, we can choose whether to create custom post types or taxonomies from the admin dashboard.
Step #2: Create a CPT / Taxonomy
In this step, navigate to the new CPT UI tab and into the Add/Edit option of the item that you would like to create. In this article, we will add a custom post type.
On this screen, we only need to fill few required fields and the plugin will do the rest.
Inside the ‘basic settings’ window, enter the desired post type slug, plural, and singular labels. Most times, the slug and the singular label are the same ones.
For example, if you would like to create a Movie custom post type, the slug that will be displayed in the URL should be singular like so:
When creating a custom post type or taxonomy, there are many more options and fields to populate with relevant information.
Many of those fields can be found in the ‘Additional labels’ section. Instead of filling them individually, click on the Populate additional labels based on chosen labels link and let the plugin fill them automatically.
Some of the additional labels that you should get familiar with are:
- Menu Position – The position in the menu order the post type should appear.
- Has Archive – Whether or not the post type will have a post type archive URL.
- Parent – Used for hierarchical types that need a colon.
- Support – Add support for various available post editor features on the right.
You can explore more options on the Pluginize documentation center website.
After clicking on the link and validating that the fields were filled with data, click on the Add Post Type button to create it.
We can now move forward to the last step and create data.
Step #3: Add a new item
After creating the new custom type, you will see its label in the admin panel bar.
Hover on it and click on ‘Add new’ to add a new row into the database.
On this screen, you’ll have all the meta options to populate just like any other default page or post.
Add a title, description featured image, and etc, and click on ‘publish’ when done.
Visit the new custom post and verify that the URL contains the slug you created in the last step.
To view the archive page (if you enabled it), trim out the last part of the URL and click enter. Example:
In the archive page, just like the blog page, all the custom types will be presented one under another in chronological order. Keep adding more items and see them stacking up.
Use a Function Instead of the Plugin
As I mentioned above, the new custom type will stop working after deactivating the CPT UI plugin. However, there is a way to keep it working after deactivating by following the steps below.
First, go to CPT UI -> Tools, click on the ‘Get Code’ tab at the top and copy the code from inside the ‘All Custom Post Type and Taxonomy Code’ (the first box) to your clipboard.
Then, go to Plugins -> Installed Plugins screen and deactivate the CPT UI plugin.
Last, go to Appearance -> File editor, click on the ‘functions.php’ file from the list on the right, scroll to the bottom of the file and paste the code.
Make sure to paste the code inside your child theme. We created an article that will teach you how to create a child theme in WordPress if you don’t have one yet.
After updating the file, you’ll see the custom post type or taxonomy back in the admin panel.
To view more custom post type plugins visit our repository and perform a search. You’ll find many good ones.
In this article, you learned how to use the CPT UI plugin to easily create custom posts in WordPress and keep your website well organized.
Please let us know which is your preferred plugin for this task or if you need any further help.