在 wordpress 导入过程中处理嵌入链接

Process embed links during wordpress import

我正在使用 WP All Import plugin 将内容导入新的 wordpress 安装。一切正常,但通常会在前端显示转换后的嵌入内容的 link 最初显示为 link。我必须手动转到 post,单击编辑器的 "Text" 选项卡,然后单击编辑器的 "Visual" 选项卡,然后处理 link。

这是正在导入的内容的示例...

<p>Below this text should be a tweet embed.</p>

https://twitter.com/someecards/status/1040642553257906180

<p>Above this text should be a tweet embed.</p>

我熟悉此导入插件允许我使用的 PHP 功能,但我找不到过滤器或任何我需要的功能。

您确定格式正确吗? o诸如 Twitter links 之类的嵌入在页面上呈现之前不会处理 link。我怀疑当您在 WYSIWYG 编辑器中编辑内容时,它会重新格式化内容以将 twitter link 单独放在一行上(这是 oembed 运行所必需的。

例如,这将不起作用:

<p>Below this text should be a tweet embed.</p>
https://twitter.com/someecards/status/1040642553257906180
<p>Above this text should be a tweet embed.</p>

但这行得通:

<p>Below this text should be a tweet embed.</p>

https://twitter.com/someecards/status/1040642553257906180

<p>Above this text should be a tweet embed.</p>

如果缺少额外的换行符是问题所在,您可以 (a) 编辑传入标记,或 (b) 在 WP All Import 中编写一个处理函数,将每个换行符变成双换行符。您还可以编写更复杂的正则表达式来查找 oEmbed URL 并将 [embed][/embed] 标记包裹在它们周围。

有关如何 oEmbeds work in WP, check out the official documentation 的更多信息。