How to enable hierarchical permalinks for hierarchical taxonomies


If you have a category called “term” and a subcategory called “subterm”, your can access subterm posts at /cat/subcat. But this doesn’t work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm.

They’ve gone over this in the WordPress Trac (, and it kind of looks like they have a solution, but as I’ve never used the Trac and don’t fully understand its language (diffs, etc), I need someone more experienced to actually tell me how to implement this. Is there code there that I have to paste into WordPress core files? Is this already implemented and I can add something to my theme’s functions.php?

If possible I’d prefer not to modify any core files. Help!

in progress 0
, , , supertrue 12 years 2011-05-15T17:08:49-05:00 0 Answer 97 views 0

Answer ( 1 )


    This is implemented in WordPress now as of 3.1.

    When you register your taxonomy, make sure to set rewrite hierarchical to true as well as the taxonomy itself:

    register_taxonomy('genre',array('book'), array(
    'hierarchical' => true, // this makes it hierarchical in the UI
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'hierarchical' => true ), // this makes hierarchical URLs

Leave an answer