• Hi,
    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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?

    Thread Starter jumust

    (@jumust)

    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 https://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 https://www.roman-kaeppeler.de/wordpress/change-category-id/?lang=en

    Thread Starter jumust

    (@jumust)

    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.

    danielpferreira

    (@danielpferreira)

    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)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change category ID’ is closed to new replies.