How to resort my id in wordpress?

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 only post post type posts, so you will never have two posts having ID’s which difference is 1

  • Not all postdata is saved in the wp_posts table. WordPress uses the wp_postmeta table to save information about attachments belonging to posts, save custom fields, save info about templates (for page post type) etc. There is also the wp_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 the wp_posts and these two other db tables. Changing post ID’s in wp_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_postand 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.