What are Custom Post Types?
WordPress is the fastest growing content management system but it was initially designed as a blogging CMS. It has over the years evolved to be a content management system that is used to build a robust website across all industries. At the core of WordPress evolution from a blogging CMS to a fully resource CMS is the custom post types.
When WordPress was designed the initial idea was to have posts and pages that could be used to publish blog posts and pages to publish static content that would not change often.
Ideally, WordPress was solving the problem of static websites by introducing a new way to easily and quickly publish new content and keep publishing more and more content without editing a single line of code.
To make WordPress more useful beyond the blog publishing Custom Post Types were introduced with the aim of allowing users to create their own types of posts that could be anything they can imagine. This custom post type allows users in diverse industries to add content to their website that relates to their business.
Custom Post Type Example
Here is a specific example: a hotel owner can use WordPress to build the hotel website and leverage on custom post types to showcase the different rooms in the hotel or the different services related to their business; standard room, deluxe room, e.t.c.
With this approach content published can be organized in the right way and managing the content becomes very easy.
Why Create Custom Post Types?
The overall reasons why we create custom post types are to extend the capabilities of WordPress to fit different needs.
Example: As a WordPress developer, artist, author or creative professional, when creating a portfolio website; you cannot use the existing WordPress post and pages to showcase your work.
You can instead create a custom post type for the portfolio and use that kind of posts to showcase your work and you will have better control and the appearance on your portfolio website.
Custom post types exist so that they can extend the core functionality of the website where the ordinary posts and pages are limited. So now how do we create the custom post types?
How to Create Custom Post Types?
There are two major ways of creating custom post types in WordPress:
- Creating custom post types with a plugin.
- Creating custom post types without a plugin.
In this article, I will focus on the second one on how to create a custom post type in WordPress without plugin. First, you need to understand the basics of how to add code in your existing WordPress theme.
Creating a Custom Post Type in WordPress without Plugin
Step 1: Name of Custom Post Type
Decide the name of your custom post type. A basic example, of the custom post type for the hotel, can be rooms where we can publish the different types of rooms in that hotel with their amenities and the prices. So we will add the name of the custom post type when we are registering it as “room”