首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大量进口光廊

大量进口光廊
EN

WordPress Development用户
提问于 2015-06-27 09:19:04
回答 1查看 233关注 0票数 1

我有这样的场景:大约200个图片库可以从一个旧的Wordpress站点在wordpress中重新创建。

我所拥有的只是post_type“照片库”的WXR,它基本上创建了图片库,并对它进行了大量的图像标识。

不幸的是,我无法导出“完整的XML”(带有图像、ids和附加的帖子),也无法访问dB。

所以基本上,我应该创建一个脚本:

读取导出的XML,检索库的原始URL (旧站点仍在运行),打开URL,获取特定的图像和文本,并将其加载到wordpress中,使用文本作为图像描述,并将其与XML中找到的post_id关联,打开库中下一个图像的链接(例如,模拟单击" next“按钮),然后循环直到加载库中的所有图像(每个图库平均为10到15 )。

有什么建议吗?

EN

回答 1

WordPress Development用户

发布于 2015-07-10 04:08:50

你将如何代表新网站上的画廊?每个画廊都是一个带有标准[gallery ids=...]短代码的帖子吗?

如果是这样的话,您基本上只需要为旧站点上的每个图像提供url (如果需要,还需要post标题/文本和图像描述),并且您可以创建一个WXR导入文件来将所有内容导入到新站点。

例如,一个带有两个图像的库的导入文件(在WP 4.2.2上进行了测试):

代码语言:javascript
复制
<?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将在导入期间跳过它们。
  • 我认为帖子必须在导入文件中的图像之前。
  • 追踪你的身份证。要将每个图像连接到相应的图库,您必须自己设置每个post和image (<wp:post_id>)。
    • [gallery ids=...]短代码中,您需要插入图像的In。
    • 每幅图片都应该作为附件注册到其图片库帖子(<wp:post_parent>)。
    • 。。因此,从一个ID开始,这个ID比新站点上的任何当前post/附件ID都要大,并计算您的上升方式(参见示例中使用ID 300、301和302的位置)。

  • <wp:attachment_url>是旧站点上的url,Wordpress可以从那里获取图像。

拥有完整的导入文件后,转到Tools > Import > Wordpress

  • (如果你还没有安装"Wordpress导入器“插件,你可能不得不安装它)
  • 选择您的文件,并单击“上载文件和导入”。
  • 在下一个屏幕上,将老用户映射到新用户(在我的示例中,所有项目都是<dc:creator>-ed,因此我只需将它们映射到这里的新站点管理员),最重要的是,检查“下载和导入文件附件”,使新站点从旧站点(通过<wp:attachment_url>中的urls )下载图像文件。
票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/192780

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档