WordPress add_filter() to add first image to RSS — causing server error

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.

Read More

Anyone give a hand re what’s going on here? I am using WordPress 3.1.2, Thesis Theme.

Thanks!

Related posts

Leave a Reply

1 comment