Use tag interface for hierarchical taxonomy?

Here’s how I did it. Just add a conditional that checks if the page being loaded is an admin page or not. If it is an admin page, set hierarchical to false, otherwise set hierarchical to true. Like so:

$args = array( 
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 
          'slug' => 'genre'
    ), 
 )

if( is_admin() ) {
    $args['hierarchical'] = false;
}

register_taxonomy('genre', array('book'), $args);

That should give you the idea. The downside to this is you can’t add parent relationships to terms using the admin interface. You could get more specific in the is_admin() conditional such as looking to see if the request contains post-new.php or post.php

Leave a Comment