Registering Custom Taxonomies for FSE
Just as Custom Post Types (CPTs) organize your content, Custom Taxonomies group that content. Whether you need "Project Types" (like Categories) or "Skills" (like Tags), registering them manually in functions.php ensures your theme is self-contained.
For Full Site Editing (FSE), the most critical argument is show_in_rest, which enables the taxonomy in the Block Editor.
1. Hierarchical vs. Non-Hierarchical
There are two main types of taxonomies:
- Hierarchical (Like Categories): Can have parents and children. Uses checkboxes in the editor. Best for strict grouping (e.g., "Department", "Service Type").
- Non-Hierarchical (Like Tags): Flat structure. Uses an input field with comma separation. Best for ad-hoc descriptors (e.g., "Skills", "Tools Used").
2. The Registration Code
Add this function to functions.php. You can register multiple taxonomies in one function or separate them.
function my_register_project_taxonomies() {
// 1. Hierarchical Taxonomy: "Project Types"
$labels_type = array(
'name' => _x( 'Project Types', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Project Type', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Project Types', 'textdomain' ),
'all_items' => __( 'All Project Types', 'textdomain' ),
'parent_item' => __( 'Parent Project Type', 'textdomain' ),
'parent_item_colon' => __( 'Parent Project Type:', 'textdomain' ),
'edit_item' => __( 'Edit Project Type', 'textdomain' ),
'update_item' => __( 'Update Project Type', 'textdomain' ),
'add_new_item' => __( 'Add New Project Type', 'textdomain' ),
'new_item_name' => __( 'New Project Type Name', 'textdomain' ),
'menu_name' => __( 'Project Types', 'textdomain' ),
);
$args_type = array(
'hierarchical' => true, // TRUE = Category style (Checkboxes)
'labels' => $labels_type,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'project-type' ),
'show_in_rest' => true, // REQUIRED for Block Editor
);
// Register and attach to 'portfolio' CPT
register_taxonomy( 'project_type', array( 'portfolio' ), $args_type );
// 2. Non-Hierarchical Taxonomy: "Skills"
$labels_skill = array(
'name' => _x( 'Skills', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Skill', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Skills', 'textdomain' ),
'popular_items' => __( 'Popular Skills', 'textdomain' ),
'all_items' => __( 'All Skills', 'textdomain' ),
'edit_item' => __( 'Edit Skill', 'textdomain' ),
'update_item' => __( 'Update Skill', 'textdomain' ),
'add_new_item' => __( 'Add New Skill', 'textdomain' ),
'new_item_name' => __( 'New Skill Name', 'textdomain' ),
'separate_items_with_commas' => __( 'Separate skills with commas', 'textdomain' ),
'add_or_remove_items' => __( 'Add or remove skills', 'textdomain' ),
'choose_from_most_used' => __( 'Choose from the most used skills', 'textdomain' ),
'menu_name' => __( 'Skills', 'textdomain' ),
);
$args_skill = array(
'hierarchical' => false, // FALSE = Tag style (Input field)
'labels' => $labels_skill,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'skill' ),
'show_in_rest' => true, // REQUIRED for Block Editor
);
register_taxonomy( 'skill', array( 'portfolio' ), $args_skill );
}
add_action( 'init', 'my_register_project_taxonomies', 0 );
3. Key Arguments
show_in_rest (Crucial)
Just like with CPTs, setting this to true exposes the taxonomy to the REST API.
- True: The taxonomy appears in the Document Sidebar in the Block Editor.
- False: The taxonomy is hidden from the Block Editor (only visible in Quick Edit or Classic Editor).
show_admin_column
If true, WordPress creates a column in the main Admin Post List (/wp-admin/edit.php?post_type=portfolio) showing the terms assigned to each post. This is highly recommended for usability.
4. FSE Templates for Taxonomies
Once registered, you can create specific templates for these archives in the Site Editor.
- URL:
example.com/project-type/web-design/ - Template File:
taxonomy-project_type.html - Generic Fallback:
archive.html
To create a specific template visually:
- Go to Appearance > Editor > Templates.
- Click Add New.
- Select Category & Taxonomy.
- Select your custom taxonomy (Project Types or Skills).