Change category ID (6 posts)

  1. jumust
    Posted 3 years ago #

    I want to change a category ID and assign to it a big ID number so that it is always the last category added.

    I think in the database I should:

    - Change the category ID
    - Re-assign to all posts with the meta old category ID the meta new category ID

    I don't know very well SQL and I'm afraid to make my database messy.

    Is there a plugin to do it easily?

  2. michael.mariart
    Posted 3 years ago #

    I don't think that would work. There's two reasons why.

    First, the categories are (under normal circumstances) listed by title, so it's ordered A-Z and the ID doesn't come into the sorting. Of course this will depend on your theme, but most themes do it this way by default.

    Secondly, categories are stored in the same DB table as posts and all other content types, so you can set the ID to a large number, but anything that's added after that will take the next available largest number due to the way that database indexing works. This meams that if you add a new category after you change everything, it will have a higher ID number anyway.

    Can you give some example of your categories and how you want them to be ordered for the posts?

  3. jumust
    Posted 3 years ago #

    Sure I will explain better.

    I have a category called "Featured" that I use to display featured posts somewhere in the theme.
    I don't want this category to be the main category when a post is created, it means that if a post belong to 2 categories (one of them is Featured) the url should not use the Featured category http://mysite.com/featured/post

    I realized that the main category is that one with smaller ID, so I should assign to the Featured category a big ID number

    here are few steps to change it in the database http://www.roman-kaeppeler.de/wordpress/change-category-id/?lang=en

  4. jumust
    Posted 3 years ago #

  5. darttiglao
    Posted 3 years ago #

    was also looking for a solution that woulndt need accessing database. what i did was quite primitive but I just created another clone category (ex: featured1), then assigned existing "featured" posts there, then I deleted the old featured catagory. This way, the newly created category will have a higher ID number.

  6. danielpferreira
    Posted 2 years ago #

    Did anyone every find a good solution for this?

    darttiglao's solution is what I've been using. But it's not very pratical... (eventual little changes in the categories may require a lot of renaming)

Topic Closed

This topic has been closed to new replies.

About this Topic