Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dotherightthing/28c195fce908431b658b9b8e2326239f to your computer and use it in GitHub Desktop.
Save dotherightthing/28c195fce908431b658b9b8e2326239f to your computer and use it in GitHub Desktop.
[Importing posts with duplicate IDs] #wordpress

Importing posts with duplicate IDs

Created: 2017.04.17

After creating my pages, I realised that I was working off a new database..

I'd forgotten to import the old database, containing the existing posts.

I opened the new and old databases up in SequelPro and was unhappy to find that some of the IDs clashed.

I searched for a way to resolve the issue in phpMyAdmin but couldn't find anything. I could have simply changed the IDs, but I was sure that this would result in broken links between the tables.

Back up!

I was importing into a Multisite, so I was super paranoid about affecting multiple sites worth of data.

I used UpdraftPlus to back up data from all of the sub sites.

WordPress Import/Export

Sounding like a dubious gangster, the WordPress Import/Export functionality was actually all that I needed.

That is, if there was a clash, WordPress didn't tell me about it, as it imported the posts without any warnings.

  1. I created a dummy site to import the old database
  2. I used Tools > Export, to export only the posts (posts were the content which I needed to add)
  3. On the target site, I installed the WordPress Importer
  4. I imported the exported XML
  5. I assigned the posts to a new author, as strangely they were attributed to an author from another site, which postdated the content
  6. Everything was fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment