如何解决在 rss 项目中添加我自己的标签 ||将自定义标签添加到现有 rss 提要的过程
这里的初学者。我有一个现有页面,可以使用短代码提取即将发生的事件。这个特定的页面已经有一个 RSS 提要,我需要向它添加我自己的自定义标签,以便还可以发送事件开始时间、结束时间和位置。我已经编写了代码,以便它动态地拉入数据,并且在查看提要 URL 时一切正常。但是,当我尝试使用提要验证器时,出现以下错误。我对此很陌生,所以我假设我没有做正确的事情。例如,我是否需要在函数文件或提要文件中定义元素?等
- 原始供稿:(不含自定义元素)
<channel>
<title>Events Example</title>
<atom:link href="https://mywebsite.com/event/feed/" rel="self" type="application/rss+xml" />
<link>https://mywebsite.com</link>
<description></description>
<lastBuildDate>Wed,21 Mar 2021 19:26:43 +0000</lastBuildDate>
<language>en-US</language>
<sy:updatePeriod>hourly </sy:updatePeriod>
<sy:updateFrequency>1 </sy:updateFrequency>
<generator>https://wordpress.org/?v=5.7</generator>
<item>
<title>First Example Event</title>
<link>https://mywebsite.com/event/first-example-event/</link>
<dc:creator><![CDATA[main user]]></dc:creator>
<pubDate>Wed,22 Mar 2021 19:26:43 +0000</pubDate>
<guid isPermaLink="false">https://mywebsite.com/?post_type=event&p=15922</guid>
<description><![CDATA[<p>example event description</p>]]></description>
</item>
- 添加的自定义元素:
<startDate><?php the_field('event_start_date'); ?></startDate>
<endDate><?php the_field('event_end_date'); ?></endDate>
<location><?php the_field('event_location'); ?></location>
<id><?php global $post;$post_slug=$post->post_name;echo $post_slug; ?></id>
- Feed URL 显示的内容
<startDate>Mar 27,2021</startDate>
<endDate>Mar 27,2021</endDate>
<location>Multiple Locations</location>
<id>first-example-event</id>
-
Feed 验证器错误:(在测试站点#1)
此供稿未通过验证。
第 30 行,第 8 列:未定义的项目元素:startDate(出现 6 次)
2021 年 3 月 27 日 -
Feed 验证器错误:(在测试站点#2 上)
所选的 Feed 格式不匹配
我错过了什么?我将如何以及在何处定义自定义元素?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。