How to Create a Custom Post Type in WordPress?

How to Create a Custom Post Type in WordPress

Sometimes the default content types that WordPress provides are not enough for creating a website for your business. 

In such a case, the custom post type option that WordPress supports comes in handy. You can go beyond the page and posts content and add your custom type. 

Any business website can, thus, easily use WordPress in their way.

This article digs a little deeper to understand what custom types are, why you should use them, and how to create a custom post type in WordPress.

What is a Custom Post Type?

Before WordPress’s 3.0 version came into the picture, it only supported content types like posts and pages. However, that’s not the case anymore. As of today, WordPress comes with five different content types, such as:

  • Post
  • Page
  • Attachment
  • Revision
  • Nav Menu

Besides that, you can now create your custom post types. For example, an online food website can have its custom post type as Reviews. You can adjust the custom fields and your custom category structure.

Another example is of popular plugins, like Woocommerce, WP Forms, etc. These plugins use their custom post types. If you’ve ever installed these plugins and you may have noticed some like this. 

Woocommerce Discussion Setting

Why Use a Custom Post Type in WordPress?

Different businesses operate in different ways. Each website has a requirement based on their business type. The default post and page custom post type may not be appropriate to represent all possible entities involved in the business.

In such a case, creating custom post types can help you publish content other than posts and pages on your website.

In the example of a food website from above, the Food Review custom type helps improve the user experience by making your content more contextual. Any specific details related to food can be presented along with it. 

How to Create a Custom Post Type in WordPress?

Creating a custom post type in WordPress can be done with two different approaches. One is by using plugins, while the other one is manually adding lines of codes in the fucntions.php file.

Using Plugins

This is the most effortless way to create your custom types in WordPress. Plugins make your task easier compared to doing it manually and also saves time. With an easy-to-use interface, plugins are handy for users from all backgrounds. Here we look at the three best plugins that you can use to create your custom type.

1. Custom Post Type UI

There’s no doubt that the Custom Post Type UI plugin is the best plugin for creating custom post types in WordPress. With over 80,000+ installations, this plugin proves to be the most desirable plugin for creating custom post types. 

The best thing about Custom Post Type UI is its outstanding UI. Once you install the plugin, you get an option to adjust the settings accordingly through its clean-looking Dashboard. 

You can create new custom post types, taxonomies, and also edit existing post types. Moreover, you can import an already existing custom type from another site and export it similarly.

Features

  • Create custom post types, custom taxonomies, and configure them.
  • Attach in-built and custom taxonomies to different post types.
  • Advanced labelling options for post types
  • Displaying the new post type or taxonomy can be challenging for some users.

2. Pods

Pods are another powerful plugin for custom posts types and taxonomies. They stand out from the rest in every aspect of design as well as functionality.

Using Pods is a unique experience in itself. It offers a wizard-like interface rather than a typical dashboard environment. It uses “pods” to create and organize the custom posts types and taxonomies created using the plugin. 

You can create your own custom settings pages for easing the process further. On top of that, you can even create advanced custom types like those that use their table structure in the database.

Features

  • Create your custom type and taxonomies
  • Create custom settings pages and advanced content types.
  • Create custom field types
  • Modern and user-friendly interface
  • Easy integration with plugins like Polylang, Gravity forms, WPML, and more

3. Toolset Types

Toolset Types is a powerful all-in-one plugin that lets you create custom post types, custom field types, and custom taxonomy. Simply put, it enables you to manage all your content types and display them easily with no coding requirements at all. 

This plugin allows you to create your one custom content type and lets you organize the content by categories. You can create custom fields to use for any custom content type. This gives you the flexibility to go beyond pages and posts content types and define your custom content type.

With Toolset Types, you can establish relationships(parent/child, many-to-many) between different posts types. It also features a built-in input validation to make sure that the data user inputs are valid. 

Features

  • Create your custom post types, field types, and taxonomy
  • No coding knowledge required
  • Built-in input validation
  • Supports relationships between different posts types
  • User-Friendly interface.

Manually

While plugins are quick and easy to use, they may not be the best option for all. For instance, if you already have plenty of plugins on your site, adding another can slow down your website. Many users ask us “Will it slow down my website if I install too many plugins”. To answer your question, we have a specific article with the same title. Do give it a read.

Likewise, another problem with plugins is that you can lose all the data and your custom post types if you ever uninstall a plugin.

So, for someone who prefers taking things in their own hands, we’ve got good news. You can create custom post types manually for a permanent solution. Creating custom post types manually also gives you more flexibility, allowing you to create content types in ways that plugins won’t permit.

Although creating post types yourself is a bit of a technical process, you can do it easily if you follow the instructions correctly. So, without further ado, let’s dive in and find out how to create a custom post type for WordPress manually.

  • Got to your website directory.
  • Locate the fuctions.php file. Open it with a text editor.
  • Insert the code below to the functions.php file :
/* Custom Post Type Start */
function create_posttype() {
register_post_type( 'Food Review',
// CPT Options
array(
  'labels' => array(
   'name' => __( 'food review' ),
   'singular_name' => __( 'FoodReview' )
  ),
  'public' => true,
  'has_archive' => false,
  'rewrite' => array('slug' => 'food review'),
 )
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

After adding the code, you’ll see a new Food Review post type in your WordPress admin dashboard. Make sure you set up permalinks before trying a new post, or you’ll come across an error. 

Conclusion

Custom posts types make your life easier by allowing you to use your WordPress site in a way that suits your personal/business needs. They help you communicate better with your audience through specific posts types for particular purposes. 

In this, we’ve listed everything you need to know about how to create a custom post type in WordPress. You can either use plugins or do it manually.

Choose the method that suits your need the best. Once you’ve set up your custom post types to suit your particular business needs, you should look at some tools to make uploading content easier. 

Docs2Site is a fantastic tool that can come in handy for every WordPress user. Uploading any kind of content to WordPress is a hassle because you have to manually reformat the text and upload the images all over again. Docs2Site allows you to export your content from Google Docs to WordPress with the formatting intact. You can upload content with a single click and move on to important things. 

Do not forget to share your experience in the comment section below.

Related Articles

Leave a Reply