I’ve set up a dev site for a client, for who we’re overhauling their existing site.
One thing I wanted to do is import all their existing news posts, and carry over any images attached to those. I’ve managed to export the attachments WP Attachment Export plugin. The xml file appears to be all fine, and the correct values for post_parent are included.
When I try to import the xml file using the standard WordPress Importer – the images are imported into the media library, and the various data that goes with it except all the post_parent values are reset to 0, meaning that they’re no longer attached to anything.
What’s going on here, and is there a work around to have the post_parent imported properly? The existing site has over a thousand media files, so clearly I don’t want to have to re-attach them manually.
Edit. Here is a sample of one of the attachments in the xml. I’ve xxxx out some of filename/titles.
<item>
<title>XXXXXXXXXX</title>
<link>http://www.xxxxxxx.com/news/xxxxxxx/attachment/xxxxxxx/</link>
<pubDate>Wed, 18 Sep 2013 04:00:21 +0000</pubDate>
<dc:creator>Emma</dc:creator>
<guid isPermaLink="false">http://www.xxxxxxx.com/wp-content/uploads/2013/09/xxxxxxx.jpg</guid>
<description></description>
<content:encoded><![CDATA[]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>3880</wp:post_id>
<wp:post_date>2013-09-18 13:30:21</wp:post_date>
<wp:post_date_gmt>2013-09-18 04:00:21</wp:post_date_gmt>
<wp:comment_status>closed</wp:comment_status>
<wp:ping_status>closed</wp:ping_status>
<wp:post_name>xxxxxxx</wp:post_name>
<wp:status>inherit</wp:status>
<wp:post_parent>3874</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type>attachment</wp:post_type>
<wp:post_password></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<wp:attachment_url>http://www.xxxxxxx.com/wp-content/uploads/2013/09/xxxxxxx.jpg</wp:attachment_url>
<wp:postmeta>
<wp:meta_key>_wp_attached_file</wp:meta_key>
<wp:meta_value><![CDATA[2013/09/xxxxxxx.jpg]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_wp_attachment_metadata</wp:meta_key>
<wp:meta_value><![CDATA[a:5:{s:5:"width";i:500;s:6:"height";i:435;s:4:"file";s:30:"2013/09/xxxxxxx.jpg";s:5:"sizes";a:3:{s:9:"thumbnail";a:4:{s:4:"file";s:30:"xxxxxxx.jpg";s:5:"width";i:220;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:30:"xxxxxxx.jpg";s:5:"width";i:340;s:6:"height";i:295;s:9:"mime-type";s:10:"image/jpeg";}s:5:"large";a:4:{s:4:"file";s:30:"xxxxxxx.jpg";s:5:"width";i:402;s:6:"height";i:350;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}}]]></wp:meta_value>
</wp:postmeta>
</item>
Cheers.
I think that importing attachments separately (which is not possible with native export) is precisely cause for your issue. Importer plugin has following code:
There is some more processing with orphans, but in a nutshell it seems that only posts in same import are being considered for parent. Which kind of make sense, since IDs at the time of export are not guaranteed to be precisely same as IDs at the time of import.
Check the size of the image is not so great , I had a problem importing and after much review and import I realized that the image where the import stopped weighed some 16mb , I guess exceed the maximum execution time or something similar on the server.