Create a custom WordPress taxonomy for posts and pages

Published - Updated

Sometimes when building website using WordPress, the standard taxonomies Categories and Tags just aren’t enough, and you need to create more. WordPress has made creating your own taxonomy easy, and you can even add your custom taxonomies to pages too. To accomplish this we use the custom WordPress taxonomy function register_taxonomy().

Creating a custom WordPress taxonomy

In the snippet below, we create a new custom taxonomy called Services and add it to the Pages post type.

add_action( 'init', 'create_taxonomy' );
function create_taxonomy() {
            'label' => 'Service',
            'hierarchical' => true,

Copy and paste the snippet into your functions.php file, which is located in the root directory of your theme.

Now, if you navigate to the WordPress admin area, and select pages, you will notice a new label called Services.

You can also read up on WordPress taxonomies here. Also, we provide a whole host of Web Development articles including code snippets to help you along your way.