1

I've written a custom import script for a bespoke CMS to output Wordpress-friendly XML so I can use WP's importer plugin to import it. The format is exactly the same, as far as I can see, but the importer fails with some generic errors:

Failed to import tag. ...(x30) Failed to import post. ...(x7 thousand)

I've created a wordpress export file form the same site (with some dummy content) and this re-imports fine on a fresh install. I've made sure the XML is the same format as this, but I still get these errors.

What am I missing?

1 Answer 1

1

After a long day of tweaking, I found there were several problems:

  1. The whitespace in the XML matters.

The importer throws errors when each item's child elements are not in the same line. Any whitespace between them will cause an indentation error and fail that row's import. This doesn't seem to matter on the actual post or page items themselves, but it does on the categories and tags.

  1. Tag-descriptions cannot contain carriage return/line feeds. Replace these with '<br />'.

  2. HTML encode ALL non alpha-numeric characters. Currency signs, cedillas/accents/umlauts, single quotes, apostrophes, hyphens and many more will all break the importer. Some are OK, but I'm not sure exactly which, so won't bother qualifying this statement, just encode the whole damn thing.

Those are the devilishly hard to spot errors that wasted so much of my time, I hope it saves you some!

1
  • Thank you so much for posting your solution! I have been trying to figure out why so many , failed to import tag, notices.. and yes I had just two or three tags with descriptions with some html code.. and line feeds. Your answer directed me to right direction to get it fixed within minutes. Thank you!
    – Asadullah
    Apr 20, 2017 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.