WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Renumbering Post IDs (4 posts)

  1. Josh Betz
    Member
    Posted 3 years ago #

    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.

  2. ambrosite
    Member
    Posted 3 years ago #

    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.

  3. GRAQ
    Member
    Posted 3 years ago #

    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.

  4. Josh Betz
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic