How to Create a Taxonomy in WordPress

A taxonomy in WordPress is a way to group and organize posts or custom post types. WordPress has two built-in taxonomies:

  • Category – hierarchical taxonomy (parent → child)
  • Tag – non-hierarchical taxonomy

You can also create a custom taxonomy, such as Subject, Department, Course, or Technology.

Step 1: Open functions.php

In your WordPress theme, open:

wp-content/
└── themes/
    └── mytheme/
        └── functions.php

Step 2: Create a Custom Taxonomy

Add the following code:

function mytheme_register_taxonomy() {

    register_taxonomy(
        'course',
        'post',
        array(
            'labels' => array(
                'name'          => 'Courses',
                'singular_name' => 'Course',
                'add_new_item'  => 'Add New Course',
                'edit_item'     => 'Edit Course',
            ),

            'public'       => true,
            'hierarchical' => true,
            'show_ui'      => true,
            'show_admin_column' => true,
            'rewrite'      => array(
                'slug' => 'course'
            ),
        )
    );

}

add_action('init', 'mytheme_register_taxonomy');

Step 3: Understand the Important Parameters

register_taxonomy(
    'course',
    'post',
    array(...)
);

Here:

ParameterMeaning
courseTaxonomy name/slug
postPost type to which taxonomy is attached
labelsNames displayed in WordPress Admin
publicMakes taxonomy publicly accessible
hierarchicalAllows parent and child terms
show_uiDisplays taxonomy in Admin
show_admin_columnDisplays taxonomy in Posts list
rewriteControls the URL structure

Step 4: Go to WordPress Admin

After adding the code, go to:

Dashboard → Posts

You should see Courses available for your posts.

You can create terms such as:

Courses
├── BCA
├── B.Sc IT
├── BBA
└── MCA

Because we used:

'hierarchical' => true

the taxonomy behaves similarly to Categories.

By admin