0

I am trying to import tens of thousands of posts from Wordpress Site 1 into Wordpress Site 2. I used WP-CLI to export and import. For import, i used the "--skip=attachment" flag, as the tens of thousands of images files were being downloaded. We are keeping the images on the original server and having them symlinked on the new site. However, the attachment ids have not changed, which means the already-extant photos on Wordpress Site 2 are being referenced.

How can I change the post ids of the attachments and in the referenced posts from Wordpress Site 2 without having to download all the files?

Thank you, in advance.

DanL
  • 91
  • 1
  • 9
  • just to clarify: By 'already-extant' you mean that Site 2 already existed, and you want to merge its photos with the ones in Site 1? Or the photos themselves already existed, just associated with Site 1 instead of 2? – Loren Rosen Mar 28 '19 at 17:50
  • @LorenRosen Yes, the former is correct. We want to bring Site1's posts and attachment posts (posts with post types of attachments and galleries) and bring it into Site 2, which means the importer needs to change the post ids and references to not overlap/overwrite site 2, however we don't want the import to download the photos/attachment files as we are going to change the urls for the attachment manually using a search and replace – DanL Mar 28 '19 at 20:53
  • two other quick questions: are the images in Site 1 on a partition of (or mostly of) their own? Can site 1 be taken down for a short time? – Loren Rosen Mar 28 '19 at 23:28
  • @LorenRosen Yes to both questions ( thanks for your time ) – DanL Mar 29 '19 at 13:45
  • Looks like there isn't a straightforward way. And an enhancement request from someone in a similar situation was rejected (see https://github.com/wp-cli/wp-cli/issues/928). So I have two ideas for workarounds. Let me know if you need more detail than I'm sketching here. (1) make (on host 1) a partition with fake 1-byte copies of all the images, and the same directory tree. Have the import copy the fakes (which should be fast). So now host 2 has a partition with fakes (but the right paths in its db). Then (on host 2) swap in the 'real' partition.... – Loren Rosen Mar 29 '19 at 17:40
  • ... (2) modify the import. looks like in `wordpress-importer.php` remove the copy files lines from `fetch_remote_file()` or perhaps remove the call to it in `process_attachment()`. – Loren Rosen Mar 29 '19 at 17:44
  • ...on addition to (1). 'fast' here is relative. There's still a bunch of overhead from creating all those directories, files, etc. Dunno if it would work or help to mass-create the file tree ahead of time. – Loren Rosen Mar 29 '19 at 18:13
  • see also the suggested 'related' question https://stackoverflow.com/questions/20026759/how-do-i-bulk-upload-images-coming-from-an-old-defunct-wordpress-site-to-a-new?rq=1 – Loren Rosen Mar 29 '19 at 18:15

1 Answers1

0

befor starting any acttion back up both sites.

  1. Export your Site1 blog’s content Tools → Export tab → posts
  2. select witch ono of your post should to export and press Download Export File you will be have a .xml file
  3. go to Site2 Tools → Import tab → wordpress and click install now
  4. Run importer now we have 2+1 way to move post's medi from site1 to site2
  5. if enable check box : Download and import file attachments all of site1 media will be dowoload to site2 host and directly import to posts
  6. if not : all of media will be show on site2 but linked to site1 host
  7. you do 5. step but In some cases, WordPress may not be able to import your posts’ images automatically. so you have to move media by your self also you can use some plugin like Auto Upload Images by ali irani