I’m not sure what your intension is in doing this, but there are a couple of very important things to consider here
-
Revisions, drafts, menus, custom post type and attachments are saved in the
wp_posts
table, not onlypost
post type posts, so you will never have two posts having ID’s which difference is1
-
Not all postdata is saved in the
wp_posts
table. WordPress uses thewp_postmeta
table to save information about attachments belonging to posts, save custom fields, save info about templates (forpage
post type) etc. There is also thewp_term_relationships
table which is used to establish a relationship between posts and its terms assigned to them. In all cases, WordPress uses the post ID to establish relationships between items in thewp_posts
and these two other db tables. Changing post ID’s inwp_posts
breaks all these relationships -
MYSQL databases has a huge maximum ID integer, which you will in all probabilty never fill. For a full break up on this, please see this post on SO
To conclude, if you don’t have a back up of your database, you are in all probabilty stuffed. As WordPress uses post ID’s to establish relationships, and you have changed the post ID’s, the only reliable method to do re-establish relationships will be to do this manually. I cannot see any other reliable method doing this
If you really need to change post ID’s, the best option will be to use a function like wp_update_post
and writing a wrapper function to do what you need. This is quite expensive operations, so you will probably time out or exhaust memory on a huge database, so you will need to break your operation up into manageable chunks and run the function a couple of times.