Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

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.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Thank you very much both of you. I had my suspicions about what Thomas was talking about. I'd vote both answers up but I lack the reputation : / –  Thirlan Mar 23 '11 at 21:24
    
Also see here - my answer mostly referred to whether the post_id field is never changed, as I thought the GUID might change, but I was wrong (in the WP codebase, anyway). :)) –  Thomas McDonald Mar 23 '11 at 21:34
add comment

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]

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.