Skip to content
WORDPRESS, PHP & DATABASE

WordPress Taxonomy Generator – register_taxonomy

Generate custom taxonomy registration code.

  • Free
  • No signup
  • Runs in your browser

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

WordPress Taxonomy Generator

About WordPress Taxonomy Generator

A taxonomy is a way to group content. WordPress already has categories and tags for posts, and custom taxonomies let you add your own, for example Subject or Level for courses, or Genre for books. Hierarchical taxonomies work like categories, with parents and children.

On the first line type the singular name and optional plural (Subject, Subjects). On the second line type the post type key it should attach to, such as course. The generator writes the registration code with admin labels, a column in the post list, REST API support and a clean URL slug.

How to use WordPress Taxonomy Generator

  1. Type the singular and plural name on line 1, and the post type key on line 2.
  2. Click Run Tool to generate the PHP.
  3. Add it to your plugin, activate it, and refresh the permalinks under Settings > Permalinks.

Example

Input

Subject, Subjects
course

Output

add_action( 'init', 'nhp_register_subject_taxonomy' );
function nhp_register_subject_taxonomy() {
    register_taxonomy( 'subject', array( 'course' ), array(
        'labels' => array(
            'name'          => 'Subjects',
            'singular_name' => 'Subject',
            'search_items'  => 'Search Subjects',
            'all_items'     => 'All Subjects',
            'edit_item'     => 'Edit Subject',
            'add_new_item'  => 'Add New Subject',
        ),
        'public'            => true,
        'hierarchical'      => true,
        'show_admin_column' => true,
        'show_in_rest'      => true,
        'rewrite'           => array( 'slug' => 'subject' ),
    ) );
}

Common uses

  • Organising a custom post type such as courses by subject or difficulty level.
  • Adding a custom category system to products, events or tutorials.
  • Creating filters and archive pages for a directory-style site.

Privacy and safety

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

Frequently asked questions

What is the difference between hierarchical and non-hierarchical?

Hierarchical taxonomies behave like categories and can have parents. Non-hierarchical ones behave like tags. The generated code uses hierarchical; change it to false for tag-style terms.

Can I attach it to several post types?

Yes. Add more post type keys inside the array, for example array( 'course', 'post' ).

Why does the archive show a 404?

Refresh the rewrite rules by saving the permalink settings, and make sure at least one published post has a term in the taxonomy.

Learn to build this yourself

Free tutorials and courses on NHP Learning cover PHP, JavaScript, SQL and WordPress, from the basics to real projects.