Editing and Organizing WordPress Category Slugs

Editing and Organizing WordPress Category Slugs

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:

  1. Login to your hosting server account.
  2. Open the MyPhpAdmin (or phpMyAdmin or anything with similar function).
  3. When the list of tables had been listed, look out for the wp_terms table. (note that I’m using the standard wp_ table prefix).
  4. Delete the terms and slugs that are not in use. Make sure you check the ID for every Posts Categories and Link Categories because everything are in the same table. To ease the job, I just clear or delete the table database. Just be careful not to delete all other table database. Just clear the 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.
  5. Also edit the 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.
  6. After clearing the database, all the categories in you blog will be removed. Just go to the Categories section and create a new category. Just start all over again. This time make sure you plan every categories nicely to avoid any mistake. If you did make a mistake. Just repeat the steps mentioned above.

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.

Share
Blog Traffic Exchange Related Posts
  • Welcome to Ridhuan's Blog Welcome to Ridhuan's Blog. This blog is focused for sharing information between bloggers so that we can help each other...
  • FlashGet My Download I've been using FlashGet for so many years I don't even remember since when or what version it was when...
  • How to Import Blog Feed to Facebook Pages Importing blog feeds to Facebook Pages saves you the effort of exporting or sharing your blog post on Facebook. Every time you...
Blog Traffic Exchange Related Websites

12 Comments »

  1. mesmerising1 Says:

    nice blog n nice info..
    ur layout so professional.. so jealous lah.. he

    comment-bottom
  2. ryanve Says:

    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.

    comment-bottom
  3. Your article are very impressive. Thank you so much

    comment-bottom
  4. mancai Says:

    huhuhu nice info… thanks

    comment-bottom
  5. farhan Says:

    maju .hhe

    comment-bottom
  6. 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.

    comment-bottom
  7. Interesting its superb, I like it Thank you

    comment-bottom
  8. [...] Editing and Organizing WordPress Category Slugs 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…… [...]

    comment-bottom
  9. MJ Says:

    @Alexandra, thank you so much for posting that, it was my problem as well and it was driving me crazy. Once I renamed the tag slug, the category was all good. Guess my tag/category architecture needs some attention

    comment-bottom
  10. thanks admin very good blog..

    comment-bottom
  11. oto anahtar Says:

    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..

    comment-bottom
  12. süper bir tasarım tebrik ederim

    comment-bottom

RSS feed for comments on this post. TrackBack URL

Leave a comment

*


Notify me of followup comments via e-mail. You can also subscribe without commenting.

Buy and Sell text links
ss_blog_claim=82d6a1cd43b9ee976ddc41a2e546c430