• Resolved Josh Betz

    (@betzster)


    So, I never thought this could possibly be something that would be an issue, but I’m looking to renumber my post IDs. Long story short: I’ve moved things around and now have only 167 posts, but my post IDs are currently in the 2660 range. I know people will say this doesn’t matter, but my shortlinks currently depend on the post ID so I’d like to renumber these to get that cleaned up.

Viewing 3 replies - 1 through 3 (of 3 total)
  • It’s going to be messy. The post ID is a foreign key in three other tables: wp_postmeta, wp_term_relationships, and wp_comments. Furthermore, the wp_posts table is self-referential — it has a field called post_parent that may contain the ID of another post (in the case of image attachments, for example). You’ll need to make sure the ID gets updated in all those places. I don’t know of any way to write a SQL query that could do this. A custom PHP script will most likely be needed.

    If it really is necessary, it might be easier to build a new installation and export/import the posts.

    It seems quite drastic for such a cosmetic change?

    Possibly you could change the slug to a number and use a /%postname%/ permalink. But that’s not an idea I would suggest, especially without testing first.

    Thread Starter Josh Betz

    (@betzster)

    Export/import keeps all the same ID’s. I’ve tried it already. I mean, it makes sense — they don’t want to deal with changing all the dependencies that are already built into that export file. I’m going to do some research into what all those dependencies are and write something up, or look at other options.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Renumbering Post IDs’ is closed to new replies.