Let’s say that you have situation like myself few days ago. You have regular wp posts and categories with some tags in it. But you need a little more. More customization, more custom things that you simply can’t done through standard wordpress taxonomy (category & tags). So let’s say that you managed to fork you’re way through wp custom post types (CPT) and you assign some custom taxonomy (CT). As you know CT can be done “like tags” (‘hierarchical’ => false,) or “like categories” (‘hierarchical’ => true,). Now you wish to transfer your current “standard” categories to custom taxonomy with hierarchy.
- Find some appropriate plugin to do all hard work (I didn’t even bother with that ), or wait for me to create one 🙂
- When you create (register) CT with hierarchy ( codex ) with name like “genre”, open phpmyadmin on your server
- Open your WordPress database
- Paste SQL code in “SQL” tab under “Run SQL query/queries on database…“
UPDATE wp_term_taxonomy SET taxonomy='genre' WHERE taxonomy='category'
Like you see, ‘genre’ stands for custom taxonomy & “category” for old, standard categories.
- Open database name “wp_term_taxonomy”
- Like you see inside that table you have all your current “standard” taxonomies like “category”, “post-tag”, “nav_menu”…
- For each category you want to transfer to CT, click on “category” under “taxonomy” column
- Rename “category” to your CT slug name (“genre” in our example) -> you assign slug name when you register custom taxonomy
- That’s all 🙂
Same thing can be done with tags. For transferring standard posts to CPT you can refer to plugin like Convert Post Types which moves multiple posts based on category… or Post Type Switcher which is little simpler version with less options.