通过 RSS 在 WordPress 中联合自定义字段
我想知道我是否可以问一个 WordPress / RSS 问题,我在这里找不到答案,
尝试使用 FeedWordpress 插件作为 RSS 聚合器,通过 WordPress 中的 RSS 联合帖子,原始博客中的每个帖子都包含五个自定义字段,对其主题功能很重要(使用相同主题的原始博客和联合/接收博客)。
原始 RSS2 提要不包含这些自定义字段,除了一个在默认 rss 提要模板中定义的附件字段(WP rss_enclosure 中的函数)之外。
这是在原始提要中编写的,例如:
<enclosure url="http://www.samplevideourl.flv" length="18554755" type="video/x-flv" />
尝试添加其余的自定义字段并修改 rss2-feed.php 模板,以便它们显示在当前 RSS2 提要中每个段的末尾,现在将它们包含在内,例如:
...
<ratings_average>0</ratings_average>
<views>5</views>
</item>
但是,如果我更新联合帖子,或删除帖子并再次使用 feedwordpress 获取修改后的提要,这些都不会显示在联合帖子中。
有没有办法包含这些自定义字段,以便 feedwordpress 识别它们?
基本上需要联合与原始帖子相同的格式,包括所有自定义字段。
非常感谢
卡洛斯
I wonder if I could ask a Wordpress / RSS question I could't find an answer for around here,
Trying to syndicate posts via RSS in Wordpress using the FeedWordpress plugin as an RSS aggregator, each post in the original blog includes five custom fields that are important for its Theme functionality (the original and syndicating / receiving blog using the same theme).
The original RSS2 feed doesn't include these custom fields apart from one, being enclosure, that is defined in the default rss feed template (function in WP rss_enclosure).
This is written in the original feed such as:
<enclosure url="http://www.samplevideourl.flv" length="18554755" type="video/x-flv" />
Tried to add the rest of the custom fields modifying the rss2-feed.php template so they show at the end of each segment in the current RSS2 feed, now they are included as for example:
...
<ratings_average>0</ratings_average>
<views>5</views>
</item>
However, if I update the syndicated posts, or delete the posts and fetch the modified feed again with feedwordpress, none of these show in the syndicated posts.
Is there a way to include these custom fields so they are recognized by feedwordpress?
Basically need to syndicate the same format of the post as the original including all its custom fields.
Many Thanks
Carlos
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个线程涵盖了这一点:https://wordpress。 stackexchange.com/questions/3801/add-custom-fields-to-custom-post-type-rss
我已经浓缩了那里的答案以反映后来的改进(感谢 MikeSchinkel、prettyboymp 和使徒行传7)。
将其添加到主题的functions.php中:
这会将所有自定义字段名称和值添加到网站的主要提要中。
请注意,对于具有多个值的自定义字段,需要进行修改,因为上述内容仅适用于单值字段,不适用于数组。
因此,
There is a thread that covers this: https://wordpress.stackexchange.com/questions/3801/add-custom-fields-to-custom-post-type-rss
I've condensed the answers there to reflect the later improvements (thanks MikeSchinkel, prettyboymp and Acts7).
Add this to your theme's functions.php:
This will add all custom field names and values to the site's main feed.
Note, for custom fields with more than one value, a modification is necessary as the above will only work for single value fields, not arrays.
So,