WordPress Importer not importing Attachments? Try exporting All Statuses!

Ever tried to export content from a WordPress site and then import it to another with the WordPress Importer only to find the attachments were not imported? You are not alone. I just spent a couple of hours troubleshooting the issue and I made a very interesting, if perplexing, discovery that may solve your problem.

First a little back story.ย Of the many things that drive people crazy and induces a burning desire to take the application for a spin in a blender is the WordPress Importer. To say the plugin is rife with problems would be an understatement. A simple Google search will show you that the importer not importing attachments is a problem that has been around for years and has yet to be dealt with properly. Not impressive in the least. Now let’s get to the point of my story.

The Problem

Here’s the scenario: Site 1 has 900+ posts of which about 800 have already been moved to Site 2 by porting the database. Now the new posts (about 100) need to be ported over using the importer. Because there are about 30 draft posts in Site 1 that have already been ported, I wanted to ignore these so in the exporter under Statuses I selected “Published”.

Run the importer and all the posts are imported but the image and attachment links are all pointing back to Site 1. Not what I want.

So I do some tinkering with the import file, move the files manually, and generally mess around with everything. This has worked in the past, but for some unexplainable reason it doesn’t work now. The attachments are not being imported.

The Solution (which makes no sense)

So, after banging my head against the keyboard for a while I decided to try something different: Instead of setting Statuses to “Published” I set it to the default “All Statuses”. The xml file appears, I import it, and behold: The attachments are imported!

The Reason (which makes even less sense)

Comparing the two export files one thing becomes immediately obvious: In the first file – in which I specified I only wanted Published statuses, the attachments are referenced in the posts, but the attachment table is ignored. In the second file – in which I exported All Statuses – the attachment table is included. In other words the WordPress export function defines Attachment posts as something other than Published. Which of course is rubbish, but whatever.

So, if you are having problems getting your attachments to import, try setting Statuses to All Statuses when you export and maybe, just maybe, you’ll get WordPress to do what you want.

20 thoughts on “WordPress Importer not importing Attachments? Try exporting All Statuses!

  1. This may help understand the crazy somewhat…

    Attachments have the post_status of “inherit” which makes perfect sense if you assume that every attachment is associated with a post. By doing this, WP saves some work on every save. It doesn’t have to check ‘Post is scheduled. Okay, let’s get all the attachments and update them.’ and it doesn’t have to update all the pages when it publishes, deletes, etc.

    Of course, you have caught the fatal flaw of this, though. The importer is too precise.

    1. From a WordPress core / developer standpoint it makes sense that this is what happening, but from a user standpoint it is counterintuitive and in contradiction to expected behaviour. The plugin needs to be updated to not apply the post_status value to the Attachments or to treat Attachments as a separate entity. I doubt anyone would ever intend to export all published posts and pages without also exporting the attachments.

      1. In my perception, it is always about: Expected behavior
        It’s the user how uses the software, and it should behave as expected If not it is just Broken

        It maybe is not in the eye of the developer, but that doesn’t matter it is in the eye of the user. This is one of the key issues that Steve Jobs addressed with “We make the best possible user expressions”

        This is a way of working the WordPress community as a whole and the core team in particular can learn a lot from.

        WordPress kind of sucks. It’s a pity, but a lot of things are kind of broken we learned to live with it as they don’t get addressed by the core team as they are not focusing on what users really need. Best possible user expressions as in: Expected behavior

        Fortunately WordPress sucks less than a lot of other Opensource CMS / blog systems. ๐Ÿ™‚ I still love the community way how things are getting build and fixed.

        But somehow, wouldn’t it be great to become great?

        Stop being just code developers point of view. Become the best possible user expressions. Don’t fix what is not broken, fix what is not expected behavior, cause that is really what is broken.

  2. OMG the #%&(#$&%(*$# WordPress Importer!!! If I bail on WP for Ghost or any other platform, the Importer will be Reason #1. I have lost so much content and so many wrist-slitting hours of frustration. How can this have been so dysfunctional for so long? Every time it doesn’t work I have to ask if I’m the only person who ever moves a site? Or if everyone else knows the “real” way to do it without the importer. I literally have years of broken links thanks to the importer. We’d be better served if it didn’t exist at all.

    kk, haha, I guess that wasn’t really about YOUR post! But the importer has so frustrated my life that I can’t pass even the slightest opportunity to vent. On forums if you get a reply at all, peeps seem surprised that there’s any trouble with this “easy to use tool.” So besides a possible solution your post suggests that I’m not *totally* crazy.

    haha, I should just stop already. You’ve roused too much anger and frustration for me to speak clearly. Anyway, I’d pretty much decided to restructure my work flow so that I NEVER move a site. Once you rent server space, it’s a commitment to use that host forever. Maybe the “hosting cartel” wrote the Importer?? Yes, the Importer definitely brings out dreams of conspiracy theories.

    Anyway, THANK YOU for anything that might help next time I have to move content, if I’m masochistic enough to ever try again. ๐Ÿ˜›

  3. WordPress needs to clean up the attachment concept. Actually get rid of it. Well it has sort of already. Just deprecate it.

    With custom posts – and attachments are now defined as a custom post – treat them that way and get rid of inheritance. Attachments aren’t digital DNA!

  4. I cannot believe this!!! Thanks for the post, i was banging my head around the same issue (imported only a taxonomy instead of the entire blog).

  5. I’ve tried this but it doesn’t work. It looks like it’s transferring the attachments but that’s only because it’s hotlinking the images from the original site.

  6. For the love of all things WP, here it is 2017 and this is STILL a problem. And, of course, WordPress, the core platform, has changed a gazillion times in the interim. But importing attachments within the WP dashboard is still a cr@p shoot and more often than not doesn’t work as expected (for the experts!) as for the every day user, I think they run from it screaming ….

    This post is an oldie but goodie!

  7. Love it if only it was this simple! This doesn’t apply to me – I have tried it 3 times!

    In the export tool, it says:

    choose what to export;

    – All content (I tick this)
    Or
    posts
    pages
    feedback
    media
    etc

    I click ‘all content’ then click download export file.

    I get the file. it’s 1832 KB. (1.8MB; the limit is 64 MB)

    I go to import. Choose file, click import.

    At ‘import attachments’ I click ‘download and import file attachments’. I click import
    One time I didn’t click this and it worked but it only installed like 1% of my blog.

    The other times I clicked this and it said that files were already installed. So I went to the media album – there were just 3 images there. I went to the posts section; just 12 posts out of 115 were there. And the import file is as a weird text file in the media library.

    Can anyone help or has any advise???? ๐Ÿ™‚

    1. SOLUTION!
      1) Run the importer like you would normall
      2) Cry a tear and smash your keyboard over your head multiple times because it makes all image calls point to the original server.
      3) download and activate the “Import External Images” plugin (it has not been updated in a while)
      4) Visit all your pages and posts and on the left the plugin will have detected the image. Check off the box and save.
      5) Drink a shot and beer and throw confetti in the air when complete.

      Yes it’s a pita but it’s better than nothing. Best wishes, keep hacking!

  8. Thanks, but how would the Teleporter Plugin solve this issue? I have imported posts from one wordpress site to another but the Featured images are all missing. How could the Teleporter Plugin help with this?

Comments are closed.