Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add categories to a WordPress custom post type, either associate the built-in category taxonomy with that post type or register a separate hierarchical taxonomy. Register the taxonomy and post type on init. For the block editor, enable REST exposure with show_in_rest => true on both the taxonomy and the post type.

Choose the right category model

Approach Terms Best when
Built-in category Shares the site’s existing category terms Your custom posts should use the same category tree as regular posts
Custom hierarchical taxonomy Has its own terms, labels and optional rewrite settings Your custom post type needs an independent category structure

In WordPress, categories are taxonomies. Adding 'category' to a post type associates the existing taxonomy; it does not create a new one. A custom taxonomy must be registered explicitly with register_taxonomy().

Option 1: share WordPress’s existing categories

If the custom post type is already registered in your code, add category to its taxonomies argument:

register_post_type(
    'book',
    array(
        'label'        => __( 'Books', 'textdomain' ),
        'public'       => true,
        'show_in_rest' => true,
        'taxonomies'   => array( 'category' ),
    )
);

Replace book with the actual post type key. The post type must be registered on init, and show_in_rest should be enabled when the block editor is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option 2: create a separate category taxonomy

Use a hierarchical custom taxonomy when the post type needs its own parent-and-child category tree:

add_action( 'init', 'my_register_book_taxonomy' );
function my_register_book_taxonomy() {
    register_taxonomy(
        'book_category',
        array( 'book' ),
        array(
            'label'             => __( 'Categories', 'textdomain' ),
            'hierarchical'      => true,
            'show_ui'           => true,
            'show_admin_column' => true,
            'show_in_rest'      => true,
        )
    );
}

Here, book_category is the taxonomy key and book is the registered custom post type key. Set hierarchical to true for category-like parent/child terms. A non-hierarchical taxonomy behaves more like tags.

show_ui displays taxonomy controls in the admin area, show_admin_column adds a taxonomy column to the post type’s list table, and show_in_rest exposes the taxonomy to the block editor and REST API. WordPress introduced taxonomy show_in_rest support in version 4.7.0.

Declare the association on the post type too

WordPress recommends declaring associated taxonomies in the post type registration for consistency, while still explicitly registering a custom taxonomy:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
register_post_type(
    'book',
    array(
        'label'        => __( 'Books', 'textdomain' ),
        'public'       => true,
        'show_in_rest' => true,
        'taxonomies'   => array( 'book_category' ),
    )
);

Register both components on init. The taxonomy’s object type array must contain the exact post type key. WordPress’s taxonomy reference warns: “Do not use before the ‘init’ hook.”

Why categories do not appear in the block editor

  1. Confirm that the post type registration includes 'show_in_rest' => true.
  2. Confirm that the taxonomy registration includes 'show_in_rest' => true.
  3. Check that the taxonomy is attached to the correct post type key, including spelling and underscores.
  4. Verify that registration runs on init, not before it.

REST exposure is required for the taxonomy control to be available in the block editor. A taxonomy can still appear in another administration context while remaining unavailable in the block editor if either REST setting is missing.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When another plugin or theme owns the post type

First identify the existing post type key and inspect its registration before adding code. If you do not control the registration, WordPress provides the register_post_type_args and register_taxonomy_args filters for adjusting arguments such as REST exposure. Avoid registering a duplicate post type or taxonomy.

Common fixes

  • No taxonomy controls: enable show_ui and confirm the taxonomy is associated with the correct post type.
  • No taxonomy column in the list screen: enable show_admin_column.
  • Terms are shared unexpectedly: use a custom taxonomy instead of the built-in category taxonomy.
  • Categories disappear after a theme change: move registration into a plugin. Theme-based registration is lost when that theme is deactivated.
  • Terms cannot be assigned: check that the taxonomy is registered for the same post type key used by the post type.

Practical decision checklist

  • Use category if these posts should reuse the site’s existing category terms.
  • Use a custom taxonomy if the posts need separate terms or labels.
  • Set hierarchical to true for parent/child categories.
  • Set show_in_rest to true on both the taxonomy and post type for the block editor.
  • Register on init and keep persistent content structures in a plugin.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.