I am trying to use this function in functions.php to grab the thumbnail of posts and add them to my RSS feed.
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');
Problem is — this crashes my server. I get a 500 error. If I comment out the add-filter
lines there’s no error.
Anyone give a hand re what’s going on here? I am using WordPress 3.1.2, Thesis Theme.
Thanks!
I’ve tested your code on my dev site and it works as expected. It may not work due to post-thumbnail support not being enabled. From the codex:
Source:
http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail