[wp-hackers] Treating categories like tags
wp at andrewnacin.com
Fri Feb 8 15:24:00 UTC 2013
On Fri, Feb 8, 2013 at 3:49 AM, David Anderson <david at wordshell.net> wrote:
> 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<http://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<http://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 problem?
Perhaps the cheapest way to do this would be to:
* Use the category to tags converter (listed as an importer in the admin)
to convert everything to tags.
* On the Permalinks screen, set the tag base to 'category', and the
category base to something else.
You'll end up with a non-hierarchical taxonomy that keeps the same URLs.
More information about the wp-hackers