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.
// 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 );
About this generator
Taxonomy Generator Online
A WordPress custom taxonomy generator that writes the complete register_taxonomy() call — hierarchical like categories or flat like tags, attached to any post types you name, with the full label set, the admin column, REST exposure, term capabilities and a default term. Export it as a snippet, a functions.php block, or a plugin file.
The Permalinks tab previews the term archive URL your rewrite settings will produce, including nested paths when hierarchical URLs are on. Everything runs in the browser: no account, no upload, nothing stored on a server.
Reviewed Output tested on WordPress 6.8 · PHP 8.3
Why the custom taxonomy generator beats a hand-written register_taxonomy() call
Taxonomy keys share a namespace with WordPress query variables. Register one called type, name, status or order and the front end starts 404ing or falling through to the home page, with nothing in the logs to explain it. This generator checks your key against the full reserved-terms list, writes the label set with the right translation contexts, and tells you when a setting will quietly do nothing.
The reserved query-variable list, checked
All eighty-five reserved terms — name, type, title, status, order, terms, year, page, s, p and the rest — are rejected as errors, because a taxonomy key that collides with a query var breaks term archives site-wide. Rewrite slugs and custom query_var values are checked against the same list.
The 32-character key limit
The taxonomy column is 32 characters wide, not 20 like post types. Anything longer is an error with a one-click truncate, and an unprefixed key gets a suggested project prefix.
Labels with the right gettext context
name and singular_name are emitted with _x() and the taxonomy general name / taxonomy singular name contexts that core itself uses, so translators see the same strings they already know. The hierarchical set (parent_item, filter_by_item) and the flat set (popular_items, separate_items_with_commas) swap automatically.
Warnings for settings that will do nothing
Hierarchical URLs on a flat taxonomy, a default term on a tag-style taxonomy, a generic count callback on a hierarchical one, and a taxonomy attached to no post type at all — each is flagged with the reason it will not behave the way the name suggests.
Registration order you can control
The init priority is exposed and defaults to 0, so the taxonomy exists before a post type registers its own rewrite rules. Register at the default priority 10 with post types attached and the generator reminds you why 0 is usually safer.
The admin column and the block editor panel
show_admin_column makes terms visible and filterable in the posts list, and show_in_rest is what puts the term panel in the block editor sidebar. Leave either off and the Checks tab says exactly what you lose.
How does the taxonomy generator work?
Name it, choose its shape, attach it to something, then export. The code panel updates on every keystroke.
- 01
Name the taxonomy
Enter the singular — Genre, Ingredient, Region. The plural and the taxonomy key follow automatically, slugified and capped at 32 characters, and both can be overridden.
- 02
Choose hierarchical or flat
Hierarchical behaves like categories, with a parent selector and checkbox meta box. Flat behaves like tags, with a comma-separated input. The label set changes with the choice.
- 03
Attach it to post types
Pick the built-in
post,pageandattachment, or type any custom post type slug. A taxonomy with nothing attached registers fine but never appears in the admin, which the Checks tab flags. - 04
Tune, check, export
Open Advanced for REST base and namespace, the rewrite slug, term capabilities and a default term, clear the checks, then copy the snippet or download the file.
Worked example — a hierarchical Genres taxonomy on posts
Key genre, hierarchical, public, with the admin column and the block editor panel on. This is the Snippet output verbatim.
/**
* 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 );Note the priority 0 on the init hook. Registering the taxonomy before post types means a post type that includes this slug in its rewrite rules can see it. Attach more than one post type and the second argument becomes an array instead of a string.
Custom taxonomies — frequently asked questions
What people actually ask once a custom taxonomy is live on a site.
What is the difference between a hierarchical and a non-hierarchical taxonomy?
Hierarchical taxonomies work like categories: terms can have parents, the editor shows a checkbox list, and URLs can nest. Non-hierarchical taxonomies work like tags: a flat list, a comma-separated input, no parents. Set hierarchical => true for the first and false for the second; the label set differs too, which is why the generator swaps parent_item for separate_items_with_commas when you flip the toggle.
Why do my custom taxonomy archive pages return a 404?
Two usual causes. Rewrite rules are stale — re-save Settings > Permalinks or flush once on activation. Or the taxonomy key collides with a reserved WordPress query variable such as type, name, status or order, in which case the request is parsed as something else entirely. The generator checks the key and the rewrite slug against the full reserved list.
How do I show a custom taxonomy in the block editor sidebar?
Set show_in_rest => true. The block editor reads taxonomies over the REST API, so a taxonomy without REST exposure registers correctly, appears in the classic editor, and is simply absent from the block editor panel. show_ui alone is not enough.
Can one taxonomy be shared by several post types?
Yes. Pass an array as the second argument to register_taxonomy(), or call register_taxonomy_for_object_type() later for a type registered elsewhere. Terms are shared across every attached type, so a term archive lists all of them unless you filter the query.
How do I set a default term for a custom taxonomy?
Use the default_term argument, added in WordPress 5.5. Give it a name, a slug and optionally a description, and WordPress assigns that term to any post saved with no term selected — the same way Uncategorised works for core categories. It suits category-style taxonomies; on a tag-style one it usually just clutters things.
Should the taxonomy or the post type be registered first?
Register the taxonomy first, at init priority 0, and the post type at the default priority 10. That order matters when the post type rewrite rules reference the taxonomy slug. The generator defaults the taxonomy hook to priority 0 for exactly this reason.
Where do I paste the code from the Taxonomy generator?
You have three good options and one bad one. Best is a small site-specific plugin — the generator can output one for you, and it keeps working when you change theme. A code-snippets plugin is fine too. A child theme's functions.php works but ties the code to that theme. Never edit the parent theme: the next update overwrites it and your code is gone.
Why isn't my new taxonomy showing up, or why do I get a 404?
Almost always stale rewrite rules. WordPress caches the URL routing table, so anything that adds URLs is invisible until that cache is rebuilt. Go to Settings → Permalinks and press Save Changes — you do not need to alter anything, just saving the page flushes the rules. Never call flush_rewrite_rules() on every page load; it is an expensive write and belongs in an activation hook.
Can I use the generated code in client work or a commercial plugin?
Yes. The output is ordinary WordPress API calls that you configured — there is no licence attached to it and no attribution required. Use it in client sites, commercial plugins and themes, or products you sell. The generated file carries a short credit comment you are free to delete.
The other Content generators in the library, plus the WordPress tools most often used alongside this one.