I need to create a XML with the content of an old site to import in WordPress with oficial WordPress Importer Plugin.
Based on XML exported by WordPress, I can create a compatible export export of my content. This export is like this example:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" ...>
<!-- xml header based on WordPress export -->
<?php foreach($posts as $post): ?>
<item>
<title><?php echo $post['title']; ?></title>
<pubDate><?php echo date('r', strtotime($post['date'])); ?></pubDate>
<dc:creator>admin</dc:creator>
<description></description>
<content:encoded><![CDATA[<?php echo $post['content']; ?>]]></content:encoded>
<excerpt:encoded><![CDATA[<?php echo $post['excerpt']; ?>]]></excerpt:encoded>
<wp:post_date><?php echo $post['date']; ?></wp:post_date>
<wp:post_date_gmt><?php echo $post['date']; ?></wp:post_date_gmt>
<wp:comment_status>open</wp:comment_status>
<wp:ping_status>open</wp:ping_status>
<wp:status>publish</wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type>post</wp:post_type>
<wp:post_password></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<category><![CDATA[<?php echo $post['category']; ?>]]></category>
<category domain="category" nicename="<?php echo StringToSlug::gen($post['category']); ?>"><![CDATA[<?php echo $post['category']; ?>]]></category>
<wp:postmeta>
<wp:meta_key>_edit_last</wp:meta_key>
<wp:meta_value><![CDATA[1]]></wp:meta_value>
</wp:postmeta>
</item>
<?php endif; ?>
WordPress imports this well. Now I want to add a thumbnail to each post. I only find examples with the id of the image post ID, like these example:
<wp:postmeta>
<wp:meta_key>_thumbnail_id</wp:meta_key>
<wp:meta_value><![CDATA[43]]></wp:meta_value>
</wp:postmeta>
Of course this do not work for me, because the content does not belong to another WordPress site.
How can I handle that? Is there any other way to import post thumbnail? Or there is another way to import posts for another non-Wordpress (nor non-Blogger/Drupal/Joomla) content?
lets say you have the following in your post’s import code:
that usually means that this record of type post is referencing another record of type attachment, so lets say you have a post with id# 5 you need to add another item somewhere with
<wp:post_type>attachment</wp:post_type>
and a<wp:post_parent>5</wp:post_parent>
like this:i hope this helps