2

Hay, does anyone know a way to display the featured image url within the RSS feed?

1 Answer 1

4
function add_featured_image_url($output) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $output = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ) . ' ' . $output;
    }
    return $output;
}

add_filter('the_excerpt_rss', 'add_featured_image_url');
add_filter('the_content_feed', 'add_featured_image_url');
6
  • I've added this to my templates functions.php file, but when i read the feed i cannot see it. Do i need to do anything else to it?
    – dotty
    Sep 7, 2010 at 14:31
  • Oh, a follow up. I'm using php's SimpleXmlElement() and reading the file through that. Will that make a difference?
    – dotty
    Sep 7, 2010 at 14:39
  • ... nope reply. any ideas?
    – dotty
    Sep 9, 2010 at 13:22
  • I missed you previous comments. There was an error in my answer, I edited it.
    – sorich87
    Sep 9, 2010 at 16:13
  • 1
    Sorich I think there's still an error, the code above will remove the post content and replace it with the url instead of adding it. Needs to be $output .= wp_get_att[...] instead of =
    – jerclarke
    Sep 11, 2010 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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