我试图在functions.php中使用这个函数来获取文章的缩略图,并将它们添加到RSS提要中。
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,论文主题。
谢谢!
发布于 2011-05-04 01:53:06
我已经在我的开发站点上测试了您的代码,它可以像预期的那样工作。它可能无法工作,因为后缩略图支持没有启用。从法典中:
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
https://stackoverflow.com/questions/5877426
复制相似问题