Custom Taxonomy Generator
Category-style or tag-style, attached to the post types you choose. register_taxonomy() with labels that read correctly in the admin.
Naming
Used in the database and in code. Max 32 characters, lowercase letters/numbers/dashes/underscores only, never a reserved query variable.
Structure
Attach to post types
Registering the pairing here keeps query filters consistent.
Register the taxonomy before the post type if you want the post type slug inside the term URL.
Behaviour
Public
Visible on the front end and in the admin.
Block editor (show_in_rest)
Column in the posts list
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io). /** * Register the Genres taxonomy. */ function mytheme_register_genre_taxonomy() { $labels = array( 'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ), 'singular_name' => _x( 'Genre', 'taxonomy singular name', 'textdomain' ), 'menu_name' => __( 'Genres', 'textdomain' ), 'all_items' => __( 'All Genres', 'textdomain' ), 'edit_item' => __( 'Edit Genre', 'textdomain' ), 'add_new_item' => __( 'Add New Genre', 'textdomain' ), 'new_item_name' => __( 'New Genre Name', 'textdomain' ), 'search_items' => __( 'Search Genres', 'textdomain' ), 'not_found' => __( 'No genres found.', 'textdomain' ), 'parent_item' => __( 'Parent Genre', 'textdomain' ), 'parent_item_colon' => __( 'Parent Genre:', 'textdomain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_admin_column' => true, 'show_in_rest' => true, ); register_taxonomy( 'genre', 'post', $args ); } add_action( 'init', 'mytheme_register_genre_taxonomy', 0 );