Will post id change when migrating to new site?

I’m creating a rather complex plugin that synchronizes posts from your server with a thirdparty server. I need to know, if you migrate your wordpress server to a new site, “can” the post ids change? If so is there another unique id?

Also, is there any other instance where a post id could change?

Read More

If the id does change and there is no other unique id then chances are I’ll just do some complex md5 signature checking and string comparison if need be.

Related posts

Leave a Reply

2 comments

  1. The wp_posts table has a guid field, which should be globally unique, and survive migrations. It is formed by taking the initial post URL, and never changed after that (when you change the title, change the website address, or migrate the posts). This should be pretty safe to base your synchronisation code on.

  2. It depends upon how the database is getting from one place to another.

    If it’s a straight copy of the database (obviously with edits for new site url): no.

    Exporting the MySQL tables and importing them back in will create a carbon copy of the database – everything will be the same.

    If you are importing (through the WP admin panel): yes.

    Import allows for posts to be added to an existing blog and so the IDs cannot remain the same – the post_id must be unique across the post table, otherwise it is useless – so if a blog already has some content with the post ids [1..120] the imported content would take the IDs of [121…n+120]