Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to get posts' featured images to show up in RSS Reader.

When I look at the raw RSS XML I can see the images are successfully being written into <description> and also under <post-thumbnail> (via a function I found on a thread here) but I don't see the images showing along with the excerpt in Google Reader, for example.

I'm using the following function / filters:

function insertThumbnailRSS($content) {
    global $post;
    if(has_post_thumbnail($post->ID)){
        $content = ''.get_the_post_thumbnail($post->ID, 'thumbnail', array('alt' => get_the_title(), 'title' => get_the_title(), 'style' => 'float:left;')).''.$content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'insertThumbnailRSS');
add_filter('the_content_feed', 'insertThumbnailRSS');

add_action('rss2_item', function(){
  global $post;

  $output = '';
  $thumbnail_ID = get_post_thumbnail_id( $post->ID );
  $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail');
  $output .= '<post-thumbnail>';
    $output .= '<url>'. $thumbnail[0] .'</url>';
    $output .= '<width>'. $thumbnail[1] .'</width>';
    $output .= '<height>'. $thumbnail[2] .'</height>';
    $output .= '</post-thumbnail>';

  echo $output;
});
share|improve this question
    
When did you add the function(s)? It sometimes takes RSS feeds a bit of time to update (saved in cache) - as mentioned here –  Zach Nov 2 '12 at 2:37
    
Zach, thanks for taking the time to answer. That was it! –  Rowe Morehouse Nov 2 '12 at 17:18
add comment

1 Answer

Zach was correct. The RSS feed updated itself with my latest changes in about an hour. This function works, and I love the ability to CSS style the image as well.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.