The ability to add Custom Post Types, Taxonomies and Custom Fields (meta boxes) make WordPress the number one CMS in the world. They are insanely useful and gives you the ability to transform a simple WordPress site into a unique CMS. Up until WordPress 3.0, Custom Posts Types weren’t supported, which was one of the biggest disadvantages compared to its rivals. Before we begin, I’d like to inform you that this is an advanced article – especially if you’re hearing these terms for the first time. I’ll try to make it comprehensive, apt for beginners. So stick around, you might learn something new!

This post will be using a free plugin called “Types” to generate these, if you would like to read in detail about them see these tutorials :

What are custom post types?

Custom post types is a feature introduced in WordPress 3.0 which allows you to add you own post/content type. Please don’t confuse the term ‘post’ with ‘blog post’ as the former is a very generic term. ‘Post type’ refers to the content type. Hence, a ‘ blog post’ or a ‘page’ is actually a type of post/content, which is predefined in WordPress. You can define your custom post type. Here’s an example to help you understand:

Suppose you’re running an entertainment site – where you add the week’s top music albums, movies, TV shows, events, etc. Each of these entities would make up a custom post type. Once you’ve registered a new custom post type – say Books, on the admin dashboard sidebar menu, you would see a new entry called Books. Here’s how it looks like:

Books - Visual Editor

How to create a new custom post type in WordPress?

Creating a new custom post type requires you to define a custom post type with the required array(s) and variables, and register it via an action in the function.php file. Sounds looney? Introducing the Types plugin. With this one-of-a-kind WordPress Swiss knife, you can create, update and edit custom post types, fields and taxonomies with nothing but a few clicks of the mouse (and keyboard of course). First, you need to download and install the Types – Custom Fields and Custom Post Types Management plugin. You could either upload the contents of the plugin via FTP or directly add it from Plugins >> Add New. Next, activate the plugin.

Then navigate to Types >> Custom Post Types and Taxonomies >> Add Custom Post Type

Add

Our objective is to add a custom post type called “Books”. Kindly note, that I have already registered 2 custom taxonomies called Genres and Authors (see tutorial below). Thus we enter the relevant data (see screenshot below) and under the “Select Taxonomies” box we check only “Genre” and “Authors”. When you’re trying out this tutorial for the first time, check “Tags” and/or “Categories” in place of “Genres” and “Authors”. Once you create a new custom taxonomy, you can edit this custom post type and change the taxonomies accordingly.

Create a new custom post type

In the Display Options tab, you could check the options (meta boxes) that would be visible by default in the Edit page for the custom post type you’re creating. I’ve selected a few which are relevant for Books.

Create a new custom post type - Display Sections tab

Since books can be hierarchical – like the Harry Potter novel series, we check the “hierarchical” option, found under the “Advanced” tab.

Create a new custom post type - Advanced tab

Once done, select Save Custom Post Type. If you’ve entered everything properly and there are no conflicts, then you should see this message:

Congratulations

Custom Taxonomies and how to create one:

Remember 9th grade Biology class? The plant/animal kingdom? That’s probably where you heard the term ‘taxonomy’. Here’s a definition:

The branch of science concerned with classification, especially of organisms and WordPress post types.

Tags and Categories are the default taxonomies in WordPress and you could create as many as you like. With the Types plugin you can quickly create new taxonomies, customizable with the multitude of options available within the plugin. Let us create 2 custom taxonomies for our custom post type – “Books”.

To create a taxonomy, navigate to Types >> Custom Post Types and Taxonomies >> Add Custom Taxonomy

Adding a taxonomy - genre of a book

  1. The first taxonomy is called “Genre” which would have a hierarchical layout – much like the default Categories. Each book can now have one or more genres.
  2. The 2nd taxonomy – “Authors” will have a flat, ‘Tags’ like layout. Now each book can have one or more authors, entered via comma separated values – just like tags.

Both these layout options – ‘flat’ and ‘hierarchical’ are found under the Advanced box. Once done, select the Save Custom Taxonomy Button.

Now that you’ve registered 2 new taxonomies, its time to edit the “Books” custom post type that you created earlier and change its specific taxonomies. I won’t be writing a step-by-step tutorial on this one – think of it as an exercise for the reader. Of course if you get stuck, I’d be more than happy to help you. Once you have edited the Books post type with the specific taxonomies, the “Custom Post and Taxonomies” page under “Types” would look something like this:

Custom Post Type

Conclusion

Custom post and taxonomies are an extremely powerful field in WordPress. Once you’ve got a hold of the two, there’s virtually no stopping you from creating almost any type of CMS. And with the help of the Types plugin, you can incorporate a multitude of custom post types and taxonomies in your website. Here’s an example of what can be achieved via custom post types:

Books


Author:

Sourav is a WordPress enthusiast, an avid gamer and a sitcom collector. His playlists include heavy metal, electronic, and new-age tracks. When he's not online, he's spending quality time with his friends and family.

Siteground Hosting
Does WPLift load fast for you? That’s because we use Siteground for hosting, WPLift readers can click here to get up to 60% off hosting for your site.

Disclosure: This page may contain affiliate links for which we will receive compensation if a purchase is made.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Leave Yours +

4 Comments

  1. Thanks for the article, but it doesn’t cover styling at all. How do i make template files for each post type?

    Is there a default template file which can be duplicated /renamed to customize a single post type listing or single post display?

    Thanks for any help

    • Hi Edward, this tutorial is intended for creating custom post types only. As Rudd pointed out, displaying custom post types is the challenge. I would recommend you to Google this. If you don’t find a satisfiable answer, then you might want to learn the basics of WordPress theme development.

  2. Rudd

    That’s really easy. Creating a CPT and Custom Tax won’t be so hard, I know that there are few tools or generators to generate the code for you. The harder part is to output or display theme in your theme.

  • Comments are Closed

Our Sponsors

SEND ME FREE STUFF!

Join our Newsletter to Receive 6 Free WordPress Themes

We will also send you our weekly Newsletter packed with the Latest WordPress Content.

We will look after your email & Never Spam!

You have Successfully Subscribed!