我有这样的场景:大约200个图片库可以从一个旧的Wordpress站点在wordpress中重新创建。
我所拥有的只是post_type“照片库”的WXR,它基本上创建了图片库,并对它进行了大量的图像标识。
不幸的是,我无法导出“完整的XML”(带有图像、ids和附加的帖子),也无法访问dB。
所以基本上,我应该创建一个脚本:
读取导出的XML,检索库的原始URL (旧站点仍在运行),打开URL,获取特定的图像和文本,并将其加载到wordpress中,使用文本作为图像描述,并将其与XML中找到的post_id关联,打开库中下一个图像的链接(例如,模拟单击" next“按钮),然后循环直到加载库中的所有图像(每个图库平均为10到15 )。
有什么建议吗?
发布于 2015-07-10 04:08:50
你将如何代表新网站上的画廊?每个画廊都是一个带有标准[gallery ids=...]短代码的帖子吗?
如果是这样的话,您基本上只需要为旧站点上的每个图像提供url (如果需要,还需要post标题/文本和图像描述),并且您可以创建一个WXR导入文件来将所有内容导入到新站点。
例如,一个带有两个图像的库的导入文件(在WP 4.2.2上进行了测试):
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/" >
<channel>
<wp:wxr_version>1.2</wp:wxr_version>
<!--A post with a little text and of course a gallery of images-->
<item>
<title>My first gallery</title>
<dc:creator><![CDATA[admin]]></dc:creator>
<description></description>
<content:encoded><![CDATA[
<p><b>Welcome to my first gallery!</b> Here are the images:</p>
[gallery ids=301,302]
]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>300</wp:post_id>
<wp:post_date>2015-03-05 16:20:00</wp:post_date>
<wp:status>publish</wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:post_type>post</wp:post_type>
</item>
<!--The images attached to that post-->
<item>
<title>Picture of a cat</title>
<dc:creator><![CDATA[admin]]></dc:creator>
<description></description>
<excerpt:encoded><![CDATA[This is a picture of a cat I found]]></excerpt:encoded>
<wp:post_id>301</wp:post_id>
<wp:post_date>2015-03-05 16:21:00</wp:post_date>
<wp:status>inherit</wp:status>
<wp:post_parent>300</wp:post_parent>
<wp:post_type>attachment</wp:post_type>
<wp:attachment_url>https://upload.wikimedia.org/wikipedia/commons/f/fc/Minka.jpg</wp:attachment_url>
</item>
<item>
<title>Picture of a dog</title>
<dc:creator><![CDATA[admin]]></dc:creator>
<description></description>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>302</wp:post_id>
<wp:post_date>2015-03-05 16:22:00</wp:post_date>
<wp:status>inherit</wp:status>
<wp:post_parent>300</wp:post_parent>
<wp:post_type>attachment</wp:post_type>
<wp:attachment_url>https://upload.wikimedia.org/wikipedia/commons/b/b7/Langhaardackel_merlin_2005.jpg</wp:attachment_url>
</item>
</channel>
</rss>这接近于进行导入所需的最小信息,但如果需要,还可以在<item>元素中添加许多其他设置,例如类别。
有几件事要注意:
<title>)必须在所有帖子和附件中是唯一的,否则Wordpress将在导入期间跳过它们。<wp:post_id>)。[gallery ids=...]短代码中,您需要插入图像的In。<wp:post_parent>)。<wp:attachment_url>是旧站点上的url,Wordpress可以从那里获取图像。拥有完整的导入文件后,转到Tools > Import > Wordpress
<dc:creator>-ed,因此我只需将它们映射到这里的新站点管理员),最重要的是,检查“下载和导入文件附件”,使新站点从旧站点(通过<wp:attachment_url>中的urls )下载图像文件。
https://wordpress.stackexchange.com/questions/192780
复制相似问题