How to Create Custom Taxonomy in WordPress

Many of you choose WordPress because they think that it has Post,Category,Tag.But what most people don’t that they can create custom taxonomy in wordpress.In this post i will tell you about What is taxonomy,How to create Custom Taxonomy in WordPress and How to display custom taxonomy.

What is Taxonomy?

Taxonomy in wordpress is one of that thing which everyone use it,but they don’t know that what they are using.Wordpress taxonomy are a way to group posts,categories, custom post types. WordPress has two very popular taxonomies that people use on a regular basis: Categories and Tags.
You can use custom taxonomy to group custom post types under a single roof.
For Example:I am using a custom taxonomy called section( to group custom post type called Deals
Now that’s you know that what is custom taxonomy,lets focus on how to create custom taxonomy in wordpress.

How to Create custom taxonomy in WordPress

I will show you you two methods by which you can create custom taxonomy in wordpress.

  1. Use a plugin (no need to code)
  2. Create custom taxonomy without any plugin

1. Use a Plugin to Create Custom Taxonomy

In this i will tell how you can create custom taxonomies using a WordPress plugin.Let’s start creating custom taxonomy.First of you need to install and activate Simple Taxonomy WordPress Plugin.
Now go to Settings » Custom Taxonomies.
Give name to your taxonomy
Fill the Form.
Name:Give a Name to your Taxonomy.
Hierarchical:Want your taxonomy to be hierarchical.If you want to create a taxonomy like categories where you can add a parent and child term then choose True, other wise choose false if you want terms to be added like tags.
Post types:Associate your taxonomy with a post types.
Auto add terms:Choose Whether you want or not to add terms automatically, choose none.
This is not done.We have to label the Taxonomials.
Label your taxonomy 1
Label your taxonomy 2
Check the above images and label your taxonomies in that manner.
And here is an example how it will look.
Add a term

2.Create Custom taxonomy without any plugin

Add the following code to theme functions.php file or in a site specific plugin(recommended) to create a hierarchical custom taxonomy like categories:

// Register Custom Taxonomy
function custom_movie() {

	$labels = array(
		'name'                       => _x( 'Movies', 'Taxonomy General Name', 'text_domain' ),
		'singular_name'              => _x( 'Movie', 'Taxonomy Singular Name', 'text_domain' ),
		'menu_name'                  => __( 'Movies', 'text_domain' ),
		'all_items'                  => __( 'All Movies', 'text_domain' ),
		'parent_item'                => __( 'Parent Movie', 'text_domain' ),
		'parent_item_colon'          => __( 'Parent Movie:', 'text_domain' ),
		'new_item_name'              => __( 'New Movie', 'text_domain' ),
		'add_new_item'               => __( 'Add New Movie', 'text_domain' ),
		'edit_item'                  => __( 'Edit Movie', 'text_domain' ),
		'update_item'                => __( 'Update Movie', 'text_domain' ),
		'separate_items_with_commas' => __( 'Separate movies with commas', 'text_domain' ),
		'search_items'               => __( 'Search Movies', 'text_domain' ),
		'add_or_remove_items'        => __( 'Add or remove Movies', 'text_domain' ),
		'choose_from_most_used'      => __( 'Choose from the most watched movie', 'text_domain' ),
		'not_found'                  => __( 'Not Found', 'text_domain' ),
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
	register_taxonomy( 'movie', array( 'post' ), $args );


// Hook into the 'init' action
add_action( 'init', 'custom_movie', 0 );

To create a non-hierarchical custom taxonomy like Tags, replace 'hierarchical' => false to 'hierarchical' => true.

Display custom taxonomy

Here is how you can display the terms you added to your custom taxonomy on your single post page.Add the single line of your code in your single.php file.

<?php the_terms( $post->ID, 'movie', 'Movies: ', ', ', ' ' ); ?>

You can add it in other files as well such as archive.php, index.php, and anywhere else you want to display the taxonomy.
In my next post i will tell you how you can create a custom page for your custom taxonomy and their terms.

[moptin id="3098"]

If you have any question about creating a custom taxonomy,then ask us through comment or If you have any suggestion then please share with us.

Some Useful Resources:

Shubham Kumar

Hey, I am Shubham and i love Blogging, Coding and exploring new things and obviously sharing my experience with you.

1 Response

  1. Manik says:

    Hi Kumar,
    Thanks for the awesome tutorial. I’m searching for something like this and finally find it here.

Leave a Reply

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