WordPress demo content import "Invalid post type" issues

Hi guys,

I have a “weird” issue here.

Recently I had couple of support calls for demo content of my themes. In both instances the WordPress importer returns many of similar errors:

  • Failed to import post tag
  • Failed to import (yes, this one is plain just like that)
  • Failed to import "XYZ": Invalid post type

Even I was able to replicate the issue when installing the demo content (and also with other ThemeForest themes I’ve bought) on localhost on my computer. It was working perfectly fine before. The only change I can think of was that I updated my theme demo websites (from where the demo images are being downloaded) to current WordPress 3.5, but I don’t think it should be a problem.

Though, when I try to install the demo content on the same server where my theme demo websites are installed, everything works fine.

This rises several questions for me and I was wondering if anybody can shed a light on them:

  1. Why there are these "invalid post type" errors during the import process? As far as I know, WordPress takes the post types directly from XML file regardless what theme is installed / what post types you are actually using. The not-existing post types should be just saved in database, so they should be imported. Why does WordPress have issues with this? (And BTW, there is no error in actual XML file - I've run through it all and as I've mentioned, the erroneous imports occurs intermittently while importing the same file.)
  2. During import process WordPress downloads only images and attachments from external server. All other data are being taken from XML file, right?
  3. As of previous question: could WordPress import fail due to bandwidth limitation to my theme demo website?
  4. Can somebody explain how the WordPress import works? How it creates WP data, how it imports images (if it import also all created formats or just the main image that is formated during the import process)?

Thank you in advance for any suggestions/ideas!

Oliver

Are you sure you have activated your theme before importing the demo content?

  1. WordPress can’t import posts of a non-existing type. In my opinion it’s a good behavior, because otherwise posts would be imported as regular posts (imagine that mess).

  2. Yes.

  3. No, posts and pages would be imported, only the images import would fail.

Thank you for reply. I realized I’ve installed demo content from different theme of mine. But those themes use the same post types so it doesn’t matter? Well, anyway I tried now and was able to install demo content fine.

However, I’ve checked the screenshots my customer sent me and he has got the theme installed, active but he still get those errors. I can’t see why…

Also thank you for your answers! I didn’t know about 1) so thanks for the tip and I agree it is good behaviour.

Post types can have the same display name, but different “ID” (the first param of the register_post_type() function) - maybe that’s the reason?

e404 said

Post types can have the same display name, but different “ID” (the first param of the register_post_type() function) - maybe that’s the reason?

No, not the case. They are the same. That’s why it puzzles me. But anyway, it worked for me now and I’m sure the customer didn’t try to import demo content from my other theme as he only bought the one so I really don’t understand why there are those import errors…

My other thought would be could it be some server settings? I mean maybe the XML file (which is around 700KB) was not imported into WordPress in whole? But wouldn’t improter script throw off some error about invalid XML then?

Personally I don’t think server settings could cause this kind of issue.

webmandesign said

Thank you for reply. I realized I’ve installed demo content from different theme of mine. But those themes use the same post types so it doesn’t matter? Well, anyway I tried now and was able to install demo content fine.

However, I’ve checked the screenshots my customer sent me and he has got the theme installed, active but he still get those errors. I can’t see why…

Also thank you for your answers! I didn’t know about 1) so thanks for the tip and I agree it is good behaviour.

as I know, custom post is own by the theme. In a short words, custom post can’t apply to other theme

Hi mailmilisku,

Thanks for the reply. This shouldn’t be a problem once the custom post has the same ID - basically same everything :wink:

As for whether custom post is theme related I don’t agree with that. In my opinion it belongs to plugin, but if we (WordPress theme authors) want to sell… :expressionless: That’s for the whole new thread :wink:

Since the release of WP 3.5 the Import Plugin hasn’t changed, so it is actually only compatible up to WP 3.4.2. I’m not sure if somebody else is having issues but I have some.

About 2 months ago I started to work for a relative big label for wp themes. (WP 3.4.2) I’ve setup a “playground” for some themes, so I can play around with them. I had NO Issues at all while I’ve setup about 12 Wordpress, each with a custom theme and the demo content (.xml). Now, I need to do that again for another 12 WP (Themes), but I have issues with each of them. I haven’t moved to another webspace, haven’t changed any settings on my current webspace or anything similar. So I guess it has something to do with the importer plugin itself. Don’t wanna blame it, but I have no idea what else could be the reason. Maybe it is because of the new media manager? And also some other minor parts of the code? Especially regarding post types and taxonomies?

Haven’t found anything for now, but hopefully I’ll find some more details to that soon.

Does anyone else experience problems with the Import?

I just tried and this was the first time I had trouble with the feature. I am not sure what the cause is, but I have done this for other Wordpress prior to version 3, so maybe its the problem.

Tried several tips and still searching for a solution. This is how I found this thread.

Thanks for sharing. :slight_smile:

Well, that’s why I opened this thread. I was frustrated that I couldn’t find a solution for this anywhere. Still don’t have it and my customer went on by creating his pages from scratch…

I wasn’t able to recreate the error since which makes is more misterious one!

Hi everyone, any fix on this issue?

I had the exact same issue after the Wordpress 3.5 release, which forced me to remove the XML data from my themes. How are other authors providing dummy content if this is the case? Are they providing an SQL database or something?

MVPThemes said

I had the exact same issue after the Wordpress 3.5 release, which forced me to remove the XML data from my themes. How are other authors providing dummy content if this is the case? Are they providing an SQL database or something?

I just contacted my theme author. Waiting for a reply.

I was told to follow the directions. I guess I couldn’t do it correctly and just did all my posts by scratch. Took some trial and error to learn the layout and features. It was probably quicker since I never got the solution either. Good luck.

http://en.forums.wordpress.com/topic/failed-to-import-xml-sample-data

I don’t think this is resolved issue yet, but it haven’t happened since to me.

As tips for you guys: firstly, activate the theme the XML is meant for (and all the possible required plugins) and then try to import the XML file.

Tip for theme authors: I know this doesn’t really resolve the issue I’ve started this thread with, but I found a good practice to move all downloadable content (images for example) in XML file at its end. By default WP creates this (or smilar) XML structure: first are imported taxonomies, then downloadable media and then content (also with downloadable media somewhere). So what I do before I distribute the theme demo XML is just open the XML file and cut and paste all the attachments post types at the end of XML file (surely before closing tags </channel></rss>). This helps when there is a problem with importing images as all the text content is imported at the beginning of the file and all attachments are being downloaded just after this text content is imported. At least something :wink:

One of my buyer had the same problem. Trying to import the .xml file, but it shows “Failed to Import: Invalid Custom Post Type”, this method resolved this issue for us, may be it would be helpful for you guys too:

Solution:

  1. Download and Install 7zip.
  2. Right click on your .XML file -> 7zip -> Add to Archive
  3. Change the “Archive format” to gzip and hit “OK”. You’ll now see your file with a .gz extension on it.
  4. Try to import/upload the file again (selecting the .gz you just created not the .xml file) and it should work.

This looks like a only solution for now, but would like to hear an explanation for this issue. :slight_smile:

RockNRollaDesigns said
  1. Change the “Archive format” to gzip and hit “OK”. You’ll now see your file with a .gz extension on it.
  2. Try to import/upload the file again (selecting the .gz you just created not the .xml file) and it should work.

Wou, if this works, I eat my head, guys! :slight_smile: And would really love to hear the explanation too :wink:

Thanks very much for sharing!

hi webmandesign, I bought your theme Les paul and I got this error “Fail to import …” . I googled it and tried many solutions but I found the answer on http://wordpress.org/support/topic/failure-to-import-and-invalid-post-type-errors same as RockNRollaDesigns answer I gzipped the xml file and re-import it.
it took a little long time to import but finally it works :slight_smile:
But you may need to delete pages and post created by the failed import.