In WordPress 2.7, when editing the categories or converting a category to a sub-category, the slugs will automatically replaced in a way you won’t really favor. For example, when you have a category ‘WordPress’ with the initial slug is ‘wordpress‘ and you want to move it into a parent category ‘Blogging’, the category slug for the ‘WordPress’ category will automatically replaced as ‘blogging-wordpress‘ instead of ‘wordpress‘. The structure will become:
yoursite.com/category/blogging/blogging-wordpress/
instead of
yoursite.com/category/blogging/wordpress/
The reason for this is because the initial slug was already in the WordPress database and converting any category to a sub-category will be as same as creating a new category. The database will not overwrite the existing slug but will create a new one. Similar problem will occur if you try to rename a category to a name you had deleted previously. Browsing in the WordPress Support Forum, I still can’t find any solution for this therefore I’ve decided to try on my own. Thank God I manage to find a solution but still required quite a messy job if you are not familiar with the database system of your hosting server.
Here’s what I did to fix all the category slugs:
wp_terms table. (note that I’m using the standard wp_ table prefix).wp_terms table database. Note that If you delete everything in the table, you have to know which ID represent your Posts Categories and which are for Link Categories because you’ll have to rebuild them again.wp_terms_taxonomy which contains the hierarchical data of your categories. If you don’t edit this table, some new categories might be automatically become sub-categories based on previous data. My version allow me to delete all post categories and tags data in this table because they will be generated again when creating new category in the WordPress admin page. Just don’t delete the link_category term or clear everything in this table because this will bring hell to you. I did this mistake earlier and I won’t help if you did the same mistake.The method worked fine for me and I know there are many people are having the same problem. Please give me your feedback for this.
Related Posts
Related Websites
nice blog n nice info..
ur layout so professional.. so jealous lah.. he
Thanks for this article. I had wanted to rename a category slug and when I looked in the terms table I saw why WP wasn’t letting me use the slug that I wanted. It was because I had already created a tag that was using the slug that slug. Once I renamed the tag slug, I was then able to rename the category slug (without making any changes in phpMyAdmin). Problem solved.
Your article are very impressive. Thank you so much
huhuhu nice info… thanks
maju .hhe
I had a similar problem, but in my case I found a simpler solution. I had a category slug I couldn’t rename, and at first I thought it was because I’d used the same category slug previously, and that even though I’d deleted it, it was still in the database.
In fact, the problem was that I was using the same slug for a tag. Once I renamed the tag slug then I was able to use the category slug.