The Complete Guide To Create WordPress Custom Post Types

Learn how to create custom post types in WordPress manually and with plugin to easily manage different type of content very easily and effiiently.

Posted on by

WordPress is the most popular Content Management System (CMS) that enables users to create websites and blogs. Even though it is highly functional, you may find that some WordPress page elements, including post types, are hard to customize by default. You can modify the content formats and make your website more functional by creating custom post types.

What Is a Custom Post Type?

WordPress has great features that help users focus on their content – from how to remove page title on WordPress to how to create different post types. Think of WordPress as a huge database that stores lots of different types of content.

This stored content is divided into Post Types that can be either default or custom. You can use custom post types if you want to break down your content into smaller sections and add additional categories.

The benefits of custom post types are numerous. Having your WordPress post type customized means that you can create each post type in accordance with your own preferences, requirements, and needs.

They also come in handy when you need to create a specific template, add particular elements, or remove any meta information. You can organize and manage your pages without changing the template hierarchy. Also, if you have a lot of different content types, you can separate custom post types from other content for a better organization.

4 Steps to Create a WordPress Custom Post Type Manually

One way to create a WordPress custom post type is to do so manually. Keep in mind that this method does require some coding skills. This is a great option for you if you don’t want to install an additional plugin.

Step 1. Register your Post Type

First of all, you have to register the post type with the register_post_type(‘name’) function. The function will not work if called before the ‘init’ action. This enables you to establish the presence of the new type on the backend page. Next, go to the right of the editor and choose functions.php from the Theme Files

	
	// Creates News Custom Post Type
   function news_init() {
    $args = array(
    'label' => 'News',
     'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array('slug' => 'news'),
    'query_var' => true,
    'menu_icon' => 'dashicons-video-alt',
    'supports' => array(
    'title',
    'editor',
    'excerpt',
    'trackbacks',
    'custom-fields',
    'comments',
    'revisions',
    'thumbnail',
    'author',
    'page-attributes',)
   );
    register_post_type( 'news', $args );
   }
   add_action( 'init', 'news_init' );
	

000webhost used a function named News to create a News stream for their website. You can use this code to create basically any page you need.

Step 2. Create Posts to Fill Up Your Custom Post Type

At this stage, you can just create example posts to test your code. To ensure the post type is working go to the WordPress dashboard, click on the new custom post type, and then, select the Add New option.

Design up to five example posts and select Publish. Now, you should have these posts displayed in the new custom type navigation menu.

Step 3. Set Up a Custom Post Type Template

A template implies a file that is designed with an overall layout to be used with one or more documents. In WordPress, templates exist within a theme and indicate how your site is displayed. When you create your own custom post type template, you control how your content is displayed on the website.

To complete this step, you need to add a new file to your theme folder. There are two ways to approach this: one is using a File Transfer Protocol (FTP), and the second is utilizing PHP and simple file editing.

Hover over to Appearance and choose Editor. Then, you need to find the name of your current theme located at stylecheet.css. Put the header.php file right of the Editor, and insert this code to the very top of your file. Don’t forget to replace the theme name with the name of your theme. 

 	
 <?php touch('wp-content/themes/theme-name/new-file.php'); ?>
 	
 

Once you’ve added the code, click Update File. Now, go to your website’s home page. You have created the new file within your theme folder. Go back to Appearance > Editor > header.php to finish. When you go to header.php, you need to completely remove the code you’ve just added and click Update File.

Go to the [name]-template.php, add the following, and click Update File. 

	
<?php
  /*Template Name: [template name]*/
     get_header();
     query_posts(array(
     'post_type' => 'news'
     )); ?>
     <?php
     while (have_posts()) : the_post(); ?>
     <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
     <p><?php the_excerpt(); ?></p>
    <?php endwhile;
    get_footer();
   ?>
	

Now your custom post type template is created. It’s time to go to the backend. Select Posts > Add New and add a name to the page. Go to the right of the editor and find Page Attributes > Template, you will see a drop-down menu. Click on Publish

Step 4. Add a Menu Option

Adding a menu for your custom post type enables users to navigate and find the new custom post type. Go to Appearance > Menus. Check the box with the name of your custom post type in the Most Recent list, click Add to Menu. Now click the Save Menu button, and you’re all set!

WordPress Plugins For Creating Custom Post Types

If you’re not into coding and technical details, we’ve got you covered. There are a lot of WordPress plugins that can do the job for you. This method is less time consuming and more simple for beginners. Here are our picks for the best custom post types plugins for WordPress.

1.  Toolset Types

toolset-wordpress-custom-post-type-plugin
toolset WordPress custom post type plugin

Toolset Types is a premium custom post types plugin with a lot of benefits. It has a modern, user-friendly interface. You will get fast support, front-end posting, and in-built input validation feature.

Also, Toolset Types allows you to design templates, lists, and archives in a way that will be appealing for your website viewers. It also enables you to connect different post types.

The pricing of Toolset types starts at $69.

2. Custom Post Type UI

Custom Post Type UI WordPress
Custom Post Type UI WordPress

Custom Post Type UI is one of the most popular custom posts and taxonomies plugin. It helps to solve the problem of registering and managing custom post types.

When you install CPT UI, you get a separate easy-to-use dashboard with all available plugin’s options and features. The plugin enables you to create new and edit existing post types on your website. It also allows you to create and custom taxonomies and attach them to post types.

CPT UI comes at no cost but has an extended version that starts at $29.

3. WCK Custom Post Types and Custom Fields Creator

Custom Post Types and Custom Fields creator WCK
Custom Post Types and Custom Fields creator WCK

Another free WordPress plugin that enables you to create and maintain custom post types, custom taxonomies, meta boxes, and custom fields for your posts and pages. It’s easy to create a new post type since you only have to go through a few settings to have your custom content ready.

If you want more functional features, you can get an upgraded version from $49.

4. Custom Post Type Maker

custom post type maker WordPress
custom post type maker WordPress

Unlike its analogs, Custom Post Type Maker is very easy to use and requires no coding skills. It is a great option for beginners because it’s interface is similar to the one of WordPress’ editor. It has all the necessary features to create and configure your custom post types and custom taxonomies.

Moreover, it gives you access to all the other custom post types you have registered on your website.

Custom Post Type Maker is free to install and doesn’t have any extended versions.

Wrap up

WordPress makes it possible to diversify the content on your website through the custom post types. Having custom posts is absolutely a must if you have specific preferences regarding the functionality of your site.

It’s up to you whether you create new custom post types manually or using WordPress plugins. Creating a custom post type manually does need coding skills since it’s a more complex method. Alternatively, you can install one of the custom post types plugins to make your website more functional and unique.

Leave a Reply

Your email address will not be published. Required fields are marked *