Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

WordPress 5.0 is out. Test all the great new features before upgrading your Live website. Read How!

How to Create WordPress Custom Post Types in Simple Steps With Plugin

Updated on April 19, 2017

5 Min Read
WordPress Custom Post Type
Reading Time: 5 minutes

When we install WordPress, we only get three built-in content types at the backend, i.e. posts, pages, and media. However, today WordPress has become quite flexible and advanced. Therefore, the approach to adding more post types have also diversified. The diversified usage demands for more content types because posts, pages, and media are not enough and here is where WordPress custom post type come in handy.

Today, I am going to discuss how to create a new custom post type in WordPress through a plugin.

What is a WordPress Custom Post Type?

In accordance to the WordPress Codex, “Custom Post Types” also known as “Custom Content Types” are the specific type of post types that can be added to your WordPress using a simple function called the register_post_type(). The function allows you to add the new custom post type in accordance to a number of specifics such as supported features, availability, and labels.

Other than that, one can find several post type that is available by default in WordPress installation.

  • Post – blog post
  • Page – static page
  • Attachment – attached media
  • Revision – post revision
  • Navigation Menu – nav menu

For further details on other post types in WordPress, please have look at custom post type codex documentation.

When it comes to custom post types, WordPress supports an unlimited number of Custom Post Types. You can create your own custom posts and can call them up, wherever you want. For example, if you run a News website and you wish to add a custom post type titled, “News”. Once created, the news post-type would have its own menu in the WordPress dashboard admin area. You can also create multiple post type as well such as: Movies, Portfolio, and much more.

So let’s begin,

Create a WordPress Custom Post Type

To create a custom post type for any particular theme on WordPress, navigate to function.php file from your WordPress theme directory then add the following code to it.

After adding this code, the News post-type will automatically appear in the Admin Area of your WordPress. To see how it will appear at the front-end of your WordPress dashboard, refer to the image below.

Creating a Custom Post Type

When you create a custom post types, it is necessary to use init for the hook in add_action(). The register_post_type() function takes the arguments.

$supports: Specifies the post type is compatible and supports all essential features.

$labels: Specifies that the post type is referred properly to the admin area.

$args: Specifies a permalink slug of the news, and a menu position located just beneath the Posts menu.

Now let’s take a look before and after adding features to our WordPress,

Before adding features,

Add New Post

After adding features,

After adding features

The above example educates individuals how to register Custom Post Types to the back-end for any WordPress theme. Now it’s time to move to the next step. Creating posts as a custom post type.

Create Posts

Let’s assume that you have successfully created a post for your WordPress website. Now you want to add this post as a custom post type on your WordPress website. To do so, first add two to three dummy News post to your site.

Create Post

Create Template & Fetching List

Once, you have developed the code, your next task will be to create a new file called template-news.php and place it in your theme folder. As soon as you have created this file, add the following code to it.

Selecting Template

Now create a new page called News from the Pages option in your WordPress dashboard and access it. You can see a Template option available in Page Attributes on the right side of your screen. Select the new template News and then click the update button. For further reference,  check out the image below.

Creating page

The result of Listing Page: The end result of how your listing page will be displayed on your website is provided below:

Listing Page Result

Add a Menu For Your Custom Post Type

To add your new custom post type as a part of the Menu options on your WordPress website, navigate to Appearance >> Menus and add the News page to your main menu. This step is necessary as it will display a navigational link to our newly created custom post type, News.

For further reference, check out the image below.

Adding Menu

And this is how your website will look on the front-end. Check out the image below:

Page result

Displaying the Detail Page of Custom Post Type

We also need to create a detail page for custom post types. To do so, we just need to add a new file called single-news.php which is located in your WordPress theme and then add the following code to it.

Now it’s time to see how your detail page looks like:

Displaying the Detail Page

Top WordPress Custom Post Types Plugins in 2018

  1. Custom Post Type UI
  2. Easy Content Types
  3. Types
  4. Pods
  5. Custom Post Type Maker

WordPress Hosting Made Convenient On The Cloud

Well, you have now learned the way to create a Custom Post Type in WordPress, a pretty complex thing to do. If you have any query or suggestion feel free to ask me, I would love to reply you back. However, hosting WordPress on Cloudways is convenient. Just deploy secure and scalable cloud servers within minutes. Click the banner below to start your free trial.

Share your opinion in the comment section. COMMENT NOW

Saud Razzak

Saud is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform. Saud is responsible for creating buzz, spread knowledge, and educate the people about WordPress in the Community around the globe. In his free time, he likes to play cricket and learn new things on the Internet. You can email him at m.saud@cloudways.com

Be the first to check out WordPress 5.0

Use our Staging feature before upgrading your website to WordPress 5.0.

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.