Updating (incrementing by X) all IDs in my WordPress


I’m making a complete redesign of a WordPress site in a new fresh WP installation. This site is an eCommerce one with WooCommerce, so I need to export ALL the WooCommerce data from my old site to be imported on my "new" site (that will have the same domain). I’ll use WPALLIMPORT suite for that but there is a problem… My actual "new" site has many IDs that matches with orders ID and maybe products IDs of the old site.

So there is there is a conflict of IDs: In the "old" website I have around 4000 orders in WooCommerce, the first ones start with IDs close to the number 5000, not all orders are consecutive, because some were deleted, that is, there could be things like this:

5000, 5001, 5002, 5050, 5051, …, 9000

The new website has NOTHING in WooCommerce (no products, no customers, and no orders). Because everything must be imported from the "old" website.

But the problem is that in the new website there are many IDs that are equal to the order numbers. Remember that WordPress uses the same IDs table (I guess) for posts, post categories, post tags, pages, Elementor plugin elements, user, library images and a lot of other things.

My idea would be to be able to increase all the IDs of my new website. I’m not really a WordPress expert, but something like this comes to mind:

UPDATE wp_posts SET id = id + 100000;

But I’m not sure if those SQL commands are enough for this, or it might break something on the website …

I don’t know what can I do to mantain all my orders IDs 🙁
Thanks for reading and forgive my bad English.

candlejack 3 months 0 Answers 15 views 0

Leave an answer