In this article, I will show you what is a custom post types in WordPress, why it is needed and I will also show you how to create them.
Sometimes people classify WordPress as just a blogging platform by mistake. In last some years, WordPress had truly evolved into a robust content management system. By default WordPress comes with post and pages as the main content types but you can create as many custom content types as you like and these custom content types are known as Custom Post Types.
Some people confuse Custom Post Types with custom WordPress theme development in which we create or customize the WordPress themes. In Custom Post Types we don’t edit themes. In this article, I will show you what is a custom post types in WordPress, why it is needed and I will also show you how to create them.
What is Custom Post Type in WordPress?
Custom post types are content types like posts and pages. As WordPress has evolved from a simple blogging platform into a robust CMS hence the term post is attached to it but a post type can be any kind of content. By default WordPress comes with these post types:-
- Post
- Page
- Attachment
- Revision
- Nav Menu
You can even create your own custom post types and name them whatever you want. For e,.g. If you run a movie review website then you can create a movie reviews post type. This post type can have different custom fields and even it can have its own own custom category structure. Some other examples of post types are:-
- Portfolio
- Testimonials
- Products etc.
Why You Should Use Custom Post Types in WordPress?
You need custom post types because when building sites sometimes you find that you are constrained either metaphorically or practically by the limitations of the WordPress default Post Types which means both posts and pages. Sometimes you are looking to create something clearly very different from either of those things. Forms is a common example: even of you use a default post type to serve the purpose, the concept doesn’t fit well.
Other place where there is a need for new post or content types is when you have created a deeply nested hierarchy within your default pages content type to get the kind of permalinks you want. For e.g. When we made our company site the first time, this was how we made a listing of all the different services we offered. We had about 30 items nested under the “Services” page. It worked but it was not the best way to do. Our advise is that if you have more than 10 pages nested under a particular parent page within WordPress then here you can get benefit by making a new content type. Apart from solving too many pages problem there are some other things where you will be best served by a custom post type.
If you are regularly using a particular post category of your blog in strange ways and then find yourself not happy with the logic in your template files to make your posts look like you want then also you should create a different content type for that.
If you are forced to hack your permalink structure to be sensitive to the category of a post to give your posts in that special category a URL, it is again a case when you should use a custom post type.
Creating a Custom Post Type
The easiest way to create a custom post type in WordPress is by using a plugin. This method is recommended for beginners as it is safe and easy way to do that.
Hence First thing you need to do is install and activate the Custom Post Type UI Plugin. After activation, the plugin will add a new menu item in your WordPress admin menu known as CPT UI. After that go to CPT UI > Add New to create a new custom post type.
Conclusion
As we have just discussed, 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 are in a situation that requires more content types than just posts and pages. Hence you can use WordPress in a way that suits your individual needs.