我想将特色图片添加到我的RSS提要中。
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = \'<p>\' . get_the_post_thumbnail($post->ID) . \'</p>\' . get_the_content();
}
return $content;
}
add_filter(\'the_excerpt_rss\', \'rss_post_thumbnail\', 20, 1);
add_filter(\'the_content_feed\', \'rss_post_thumbnail\', 20, 1);
此代码段显示缩略图,但生成的内容不正确。它显示为短代码,且未格式化。。。
当我使用下面的代码段时,我删除了过滤器的顺序,显示了内容,但缺少了特征图像:
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = \'<p>\' . get_the_post_thumbnail($post->ID) . \'</p>\' . get_the_content();
}
return $content;
}
add_filter(\'the_excerpt_rss\', \'rss_post_thumbnail\');
add_filter(\'the_content_feed\', \'rss_post_thumbnail\');