WordPress RSS: Add image

If you would like to show ‘Featured Images’ in WordPress RSS feed, you need to add the following code in functions.php file for your WordPress theme:

add_action('rss2_item', 'add_my_rss_node');
function add_my_rss_node( ) {
  if( has_post_thumbnail() ):
    $thumbnail = wp_get_attachment_url (get_post_thumbnail_id ());
    echo "<image>{$thumbnail}</image>";
  endif;
}

 

Leave a Reply

Your email address will not be published.

Yandex.Metrica