WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am able to add a post featured image to the RSS feed like so:

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

However, upon examining the XML generated for the RSS feed, I noticed it sticks the featured image into the XML description item tag.

How can I insert post featured image into it's own RSS feed item tag of let's say "image", rather than just inserting it in with the post's content?

share|improve this question
up vote 3 down vote accepted

You could do it by adding an action to the hook 'rss2_item' like so:

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 answer
I found this after hours researching... great solution, thanks! – cawecoy May 6 at 23:00

Your Answer


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.