[wp-hackers] Treating categories like tags

David Anderson david at wordshell.net
Fri Feb 8 08:49:30 UTC 2013


I've got a site where the owner has so many categories, that he prefers 
to have the "categories" box on the post page appear like the "tags" box 
- i.e. have it not display the kitchen sink, but instead auto-complete, 
with an optional cloud.

A quick experiment shows that this can be changed by editing 
create_initial_taxonomies in wp-includes/taxonomy.php, and finding the 
register_taxonomy call, changing the 'hierarchical' parameter from 
'true' to 'false', and adding in some new 'labels' parameters (because 
by default non-hierarchical taxonomies get called 'tags').

However this leaves me with a couple of questions that I'm not sure on 
the best way to deal with. Can anyone advise?

* By making it non-hierarchical, hierarchy pages disappear (e.g. 
www.example.com/category/parent-cat/child-cat is now a 404). I suppose 
the owner will want these to automatically redirect, in this example to 
www.example.com/category/child-cat. What would be the best practice on 
how to do this? (It may be a moot question, as I haven't checked that 
the owner has any nested categories. But I and perhaps others would 
learn something anyway).

* Are there likely to be any other issues in converting an existing 
hierarchical taxonomy to a non-hierarchical one? In particular, any 
issues in converting this particular, built-in-default one? What 
side-effects might this have; or is there a better way I can solve my 

Many thanks,

WordShell - WordPress fast from the CLI - www.wordshell.net

More information about the wp-hackers mailing list