WordPress Custom Post Types

Last Updated:July 5, 2021

Do you want to create different post types that normal posts or pages?.

If your answer is yes then you can create the custom post type.

There are two ways to create a custom post in WordPress. You can use a WordPress Plugin to create a custom post or you can use the manual method by adding some code to function.php file in the theme directory.

The manual method of creating a custom post

If you are a WordPress Plugin Developer this is method is very important to master.

Templates for Custom Post types

WordPress support separate template for the custom post types.

When you have custom post, WordPress will go through the template hierarchy and assign the the template which matches first.

If you do not create a separate template for your customer post WordPress uses the single.php for the custom post type and to display archives, it uses the archive.php.

If you have created a custom post type name company then you can have the following templates

single-company.php  –  display the single custom post type company

archive-company.php – display the archive of the post type company

How to add metabox to customer post

Creating just custom post type in WordPress is not enough to store data. You have to create MetaBox related to the custom post.

If you do not know about the WordPress MetaBox you can read our article on How to create MetaBox