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:
| Parameter | Meaning |
|---|---|
course | Taxonomy name/slug |
post | Post type to which taxonomy is attached |
labels | Names displayed in WordPress Admin |
public | Makes taxonomy publicly accessible |
hierarchical | Allows parent and child terms |
show_ui | Displays taxonomy in Admin |
show_admin_column | Displays taxonomy in Posts list |
rewrite | Controls 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.