首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将第一个映像添加到RSS -导致服务器错误的Wordpress add_filter()

将第一个映像添加到RSS -导致服务器错误的Wordpress add_filter()
EN

Stack Overflow用户
提问于 2011-05-04 01:07:31
回答 1查看 952关注 0票数 1

我试图在functions.php中使用这个函数来获取文章的缩略图,并将它们添加到RSS提要中。

代码语言:javascript
复制
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');

问题是--这让我的服务器崩溃。我得到了一个500错误。如果我注释掉add-filter行,就没有错误。

有人帮忙吗?这是怎么了?我使用Wordpress 3.1.2,论文主题。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2011-05-04 01:53:06

我已经在我的开发站点上测试了您的代码,它可以像预期的那样工作。它可能无法工作,因为后缩略图支持没有启用。从法典中:

代码语言:javascript
复制
To enable Post Thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file.

来源:

http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5877426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档