0

伙计们初学者在这里。我有一个现有页面,该页面使用简码引入即将发生的事件。这个特定页面已经有一个 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&#038;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 日

  • 提要验证器错误:(在测试站点#2)
    选择的提要格式不匹配

我错过了什么?我将如何以及在哪里定义自定义元素?

4

0 回答 0