WordPress Development & Code

How to Add Categories and Tags to WordPress Pages

Learn how to add categories and tags to WordPress pages to improve site navigation. Here is the exact PHP snippet to enable them on your site cleanly without bloated plugins.

Dean Davis
Dean DavisWordPress Web Designer in Basingstoke
November 6, 20246 min read
Categories and tags on WordPress pages - Dean Davis

The other day, I needed to add categories and tags to pages on one of my WordPress client builds. Like many developers, I initially thought: “Aren’t categories and tags just reserved for blog posts?” It turns out that enabling them on static pages can be incredibly valuable.

Categories and tags help organise content. Categories are broad hierarchical groups that link similar topics, while Tags are specific non-hierarchical labels that connect individual pieces of content sharing a common trait.

Think about pages for services, case studies, or regional landing pages. Adding categories and tags keeps your site architecture organized, helps visitors explore related service hubs, and empowers search engines to better crawl and understand your internal link structure.

1Understanding Categories vs. Tags for Pages

WordPress limits taxonomies to standard blog posts by default. However, when you have large corporate websites with dozens of service pages, grouping them with native taxonomies brings significant benefits:

Categories (Hierarchical)

Broad umbrella groupings (e.g. Commercial Services, Residential Services, Consulting) with support for nested parent/child relationships.

Tags (Non-Hierarchical)

Granular topic keywords (e.g. Basingstoke, E-commerce, Maintenance) connecting pages across different parent sections.

2Method 1: Adding PHP Code to functions.php

Add this clean snippet to your child theme's functions.php file:

/**
 * Enable Categories & Tags on WordPress Pages
 */
function add_taxonomies_to_pages() {
    register_taxonomy_for_object_type('category', 'page');
    register_taxonomy_for_object_type('post_tag', 'page');
}
add_action('init', 'add_taxonomies_to_pages');

/**
 * Ensure Sidebar Meta Boxes Display in Page Editor
 */
function add_taxonomy_meta_boxes_to_pages() {
    add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'page', 'side', 'default');
    add_meta_box('tagsdiv-post_tag', __('Tags'), 'post_tags_meta_box', 'page', 'side', 'default');
}
add_action('admin_init', 'add_taxonomy_meta_boxes_to_pages');

3Method 2: Creating a Lightweight Custom Plugin

If you want this feature to persist across theme changes, create a single-file plugin:

  1. In wp-content/plugins/, create a folder named page-taxonomies.
  2. Inside that folder, create a file named page-taxonomies.php.
  3. Paste the following code into the file and activate it under Plugins > Installed Plugins:
<?php
/**
 * Plugin Name: Page Taxonomies
 * Description: Enables categories and tags for static WordPress pages.
 * Version: 1.0
 * Author: Dean Davis
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

function pt_add_taxonomies_to_pages() {
    register_taxonomy_for_object_type('category', 'page');
    register_taxonomy_for_object_type('post_tag', 'page');
}
add_action('init', 'pt_add_taxonomies_to_pages');

function pt_add_taxonomy_meta_boxes_to_pages() {
    add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'page', 'side', 'default');
    add_meta_box('tagsdiv-post_tag', __('Tags'), 'post_tags_meta_box', 'page', 'side', 'default');
}
add_action('admin_init', 'pt_add_taxonomy_meta_boxes_to_pages');

4Displaying Categories and Tags on the Frontend

To render the terms dynamically inside your theme’s page.php template within the WordPress Loop:

// Display Categories:
$categories = get_the_category();
if ( ! empty( $categories ) ) {
    echo '<div class="page-categories"><strong>Categories:</strong> ';
    foreach( $categories as $category ) {
        echo '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a>, ';
    }
    echo '</div>';
}
// Display Tags:
$tags = get_the_tags();
if ( ! empty( $tags ) ) {
    echo '<div class="page-tags"><strong>Tags:</strong> ';
    foreach( $tags as $tag ) {
        echo '<a href="' . esc_url( get_tag_link( $tag->term_id ) ) . '">' . esc_html( $tag->name ) . '</a>, ';
    }
    echo '</div>';
}

Conclusion & SEO Benefits

Adding categories and tags to WordPress pages is a lightweight, efficient technique to organize complex websites, enhance user navigation, and strengthen your internal SEO linking hierarchy without adding heavy plugin overhead.

Dean Davis
Written By

Dean Davis

Freelance web designer and WordPress developer in Basingstoke creating high-performance, bespoke websites and tutorials for modern businesses.

Looking for custom WordPress development? Let's talk
Custom WordPress Engineering

Need bespoke WordPress development?

Fast, secure, and tailored WordPress websites crafted to your exact specifications.

Start Your Project