Hosting Coupon Code | 3 Months | 100% OFF Get Offer

How To Create Custom Taxonomies In WordPress

Moeez — July 21, 2017 2 Minutes Read
Custom Taxonomies In WordPress

Not many people know what Taxonomy means in WordPress, even when they use the feature almost daily. Taxonomy in WordPress is a way of grouping posts (native and custom posts types) together in easily manageable groups. For WordPress users, the popular taxonomy options are Categories and Tags. In many cases, you might need to create custom taxonomies in WordPress websites to better organize your content.

In this tutorial, I will discuss how to:

  • Create custom taxonomy
  • Create non hierarchical custom taxonomy
  • Display custom taxonomy

Create Custom Taxonomy

I will start by adding a taxonomy “Topics” in WordPress. For this, add the following code in the functions.php (located in the theme folder):

Create Non-hierarchical Custom Taxonomy

Non-hierarchical taxonomy is distinct from the existing slug-based taxonomy of WordPress.

In the following code, you will notice “hierarchical=>false”. When used, this specifies metabox format WordPress also uses for Post Tags. however, in the case of “hierarchical=>false”, the metabox format is for WordPress categories.

Again, for creating non-hierarchical custom taxonomy options, add the following code in the functions.php (located in the theme folder)

Display Custom Taxonomy

Once you have created custom taxonomy in WordPress, the next step is to display them on post pages. Fortunately, this is a matter of adding the following single line of code to the single.php (located in the theme folder):

By default custom taxonomies use the archive.php template to display posts. However, you can create a custom archive display for custom taxonomies by creating taxonomy-{taxonomy-slug}.php,where taxonomy-slug refers to slug of custom taxonomy.

Get Blazing Fast WordPress Hosting With
$25 FREE CREDIT

Use Promo Code: WPB25

Conclusion

In this tutorial I have discussed how to create custom taxonomies in WordPress manually. WordPress custom taxonomies is a great way of further categorizing the content on your website. If you need help with the issue, do leave a comment below.

Subscribe to Get a FREE WordPress Ebook Right in Your Inbox

WPblog provides the complete guide to launch your WordPress website completely FREE!

Moeez is ‘The’ blogger in charge of WPblog. He loves to interact and learn about WordPress with people in the WordPress community. Outside his work life, Moeez spends time hanging out with his friends, playing Xbox and watching football on the weekends. You can get in touch with him at moeez[at]wpblog.com.

THERE'S MORE TO READ

Newsletter