php - 照片 RSS 提要显示

标签 php wordpress rss

我有一个 wordpress 博客 http://cgvector.com我想在 RSS Feed 中显示精选图片。我怎样才能做到这一点?我的订阅地址是:http://feeds.feedburner.com/cgvector

我已经添加了这段代码,但它不起作用。

function featuredtoRSS($content) {
    global $post;

    if ( has_post_thumbnail( $post->ID ) ){
    $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content;
    }

    return $content;
}

add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');

最佳答案

function custom_feed($content) {
    return wp_get_attachment_image(get_post_thumbnail_id(), 'full') . '<br />' . $content;
}
add_filter('the_content_feed', 'custom_feed');

这个应该可以为您解决问题...

关于php - 照片 RSS 提要显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11100485/

相关文章:

svn - Subversion 提交评论的 RSS/Atom 提要

php - 类中的排序函数

php - 值作为 2147483647 插入数据库

WordPress插件翻译问题

php - 如何在wordpress中仅获取特色图片的url

javascript - rss 提要谷歌媒体 :group

php - 在正则表达式中,当您向 .+ 添加问号时会发生什么变化

php - Codeigniter:用于添加和编辑帖子的一个 View

php - WooCommerce - 新的运输方式 - 如何查询单个产品重量

javascript - Google Ajax Feed API - 如何更改日期格式?