我已经尝试了插件RSS管理器,将特色图像添加到RSS提要,并在RSS提要中添加特色图像。但他们所做的只是在<description>
xml提要的属性。
这至少有两个问题:
- 推送提要的博客截断了
<description>
大约300个字符就可以了<featuredimage> 或<thumbnail>
或者类似的东西。未嵌入内部<description>
.我已经搜索了插件,但找不到任何解决此问题的插件。提前谢谢。
我已经尝试了插件RSS管理器,将特色图像添加到RSS提要,并在RSS提要中添加特色图像。但他们所做的只是在<description>
xml提要的属性。
这至少有两个问题:
<description>
大约300个字符就可以了<featuredimage> 或<thumbnail>
或者类似的东西。未嵌入内部<description>
.我已经搜索了插件,但找不到任何解决此问题的插件。提前谢谢。
RSS2馈送在wp-includes/feed-rss2.php
文件在此文件中,有一个名为rss2_item
. 您可以使用此操作挂钩向提要中的每个项目添加标记。
有一个codex article on rss2_item
示例包括添加<image>
标签:
<?php
add_action(\'rss2_item\', \'add_my_rss_node\');
function add_my_rss_node() {
global $post;
if(has_post_thumbnail($post->ID)):
$thumbnail = get_attachment_link(get_post_thumbnail_id($post->ID));
echo("<image>{$thumbnail}</image>");
endif;
}
?>
Working code:
add_action(\'rss2_item\', \'custom_thumbnail_tag\');
function custom_thumbnail_tag() {
global $post;
if(has_post_thumbnail($post->ID)):
$thumbnail_ID = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src($thumbnail_ID, \'thumbnail\');
echo("<thumbnail>{$thumbnail[\'0\']}</thumbnail>");
endif;
}
我正在尝试做同样的事情。到目前为止,我一直在寻找一些资源:
首先学习有效的RSS语法和结构。RSS2.0 Tag Syntax
在Wordpress中创建一个隐藏页面来创建您自己的布局,并调用任何和所有您想要的字段和图像。Yoast Custom RSS Feed tut
因此,我通过这段代码将我的视频自定义帖子类型添加到我的rss提要中。//Add videos custom post type function myfeed_request($qv) { if (isset($qv[\'feed\']) && !isset($qv[\'post_type\'])) $qv[\'post_type\'] = array(\'post\', \'videos\'); return $qv; } add_