如何将特色缩略图添加到导入XML中?

时间:2014-04-07 作者:Nikhil

这是一个示例项目,我正试图将其作为帖子插入WordPress。

<item>
    <title>XXXXXX</title>
    <link>xxxx/xxxxx</link>
    <pubDate>2012-05-23 19:31:00</pubDate>
    <dc:creator><![CDATA[admin]]></dc:creator>
    <guid isPermaLink="false">http://wordpress/?p=xxxx</guid>
    <description></description>
    <content:encoded><![CDATA[Sample]]></content:encoded>
    <excerpt:encoded><![CDATA[]]></excerpt:encoded>
    <wp:post_id>27505</wp:post_id>
    <wp:post_date>2014-04-05 10:01:11</wp:post_date>
    <wp:post_date_gmt>2014-04-05 10:01:11</wp:post_date_gmt>
    <wp:comment_status>open</wp:comment_status>
    <wp:ping_status>open</wp:ping_status>
    <wp:post_name>xxxxxx</wp:post_name>
    <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 domain="category" nicename="blog"><![CDATA[blog]]></category>
</item>
如何将一个特色图像导入到这个XML中,有没有方法可以做到这一点?

1 个回复
最合适的回答,由SO网友:Nikhil 整理而成

找到了有效的解决方案,

This is the post item

<item>
    <title>title1</title>
    <pubdate>2013-02-20 10:33:58</pubdate>
    <dc:creator>
    <![CDATA[ David Jennings ]]>
    </dc:creator>
    <guid ispermalink="false">http://wordpress/?p=1234</guid>
    <description>
    <title>Title</title>
    </description> 
    <content:encoded>
    <![CDATA[ABCD]]>
    </content:encoded>
    <excerpt:encoded>
    <![CDATA[ ]]>
    </excerpt:encoded>
    <wp:post_id>1234</wp:post_id>
    <wp:post_date>2013-02-20 10:33:00</wp:post_date>
    <wp:post_date_gmt>2013-02-20 10:33:00</wp:post_date_gmt>
    <wp:comment_status>open</wp:comment_status>
    <wp:comment_status>open</wp:comment_status>
    <wp:ping_status>open</wp:ping_status>
    <wp:post_name>title1</wp:post_name>
    <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 domain="category" nicename="blog"> <![CDATA[ blog ]]> </category>
    <wp:postmeta>
    <wp:meta_key>_thumbnail_id</wp:meta_key>

    <wp:meta_value><![CDATA[888888]]></wp:meta_value>

    </wp:postmeta>
</item>

This is the attachment item

<item>
    <title>title2</title>
    <link>http://wordpress/?attachment_id=888888</link>
    <pubDate>Mon, 07 Apr 2014 07:04:24 +0000</pubDate>
    <dc:creator><![CDATA[admin]]></dc:creator>
    <guid isPermaLink="false">http://wordpress/wp-content/uploads/xx/xxx/image.jpg</guid>
    <description></description>
    <content:encoded><![CDATA[]]></content:encoded>
    <excerpt:encoded><![CDATA[]]></excerpt:encoded>

    <wp:post_id>888888</wp:post_id>

    <wp:post_date>2014-04-07 07:04:24</wp:post_date>
    <wp:post_date_gmt>2014-04-07 07:04:24</wp:post_date_gmt>
    <wp:comment_status>open</wp:comment_status>
    <wp:ping_status>open</wp:ping_status>
    <wp:post_name>title2</wp:post_name>
    <wp:status>inherit</wp:status>

    <wp:post_parent>1234</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://wordpress/wp-content/uploads/xx/xxx/image.jpg</wp:attachment_url>
    <wp:postmeta>
    <wp:meta_key>_wp_attached_file</wp:meta_key>
    <wp:meta_value><![CDATA[/xx/xxx/image.jpg]]></wp:meta_value>
    </wp:postmeta>
</item>
为附件和帖子创建帖子

结束

相关推荐

GUID not updated on import

我已经从dev服务器导出了数据,并将其导入到prod服务器一个模板列出了子页面和使用$page->guid 获取指向页面的链接。问题是这个链接仍然指向我的内部dev服务器。还有其他人有类似的问题吗?如果是,我如何解决它而不必直接编辑数据库?