DEV Community

elinabey
elinabey

Posted on

How to Add Featured Image in WordPress RSS Feed

Add Featured Image in WordPress RSS Feed

Featured Image in WordPress RSS Feed. If you use an RSS feed on your WordPress website, you'll notice that the featured image isn't included in your RSS feed's posts by default. Having an RSS feed with images will enhance your syndication and may come in handy later because marketing tools like Mailup, Aweber, MailChimp use RSS feeds to create newsletters. RSS really means simple syndication.

In this brief guide, I will show you how to show your featured image in WordPress RSS feed using a plugin and without a plugin.

Featured Image in WordPress RSS Feed (Manually)

If you are familiar with modifying your functions.php file, you can use the code below to display the prominent Featured images in your RSS feed.

  1. Login to your WordPress Dashboard.
  2. Go to Appearance >> Theme Editor.
  3. Click on function.php
  4. Add given code in the bottom of function.php file.
  5. That's All, Click on Update file.

You can also add this code by using FTP.

Featured Image

/**
 * Featured image to RSS Feed.
 */
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}

add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
Enter fullscreen mode Exit fullscreen mode

Copy the above code and paste it into your function.php file. If you don't know what you are doing with the function first make a backup.

I shared this post from Add Featured Image in WordPress RSS Feed you can read in detail from there. Also they have provided easy way by using a plugin.

If you have any question please discuss below help to improve. Thank you.

Top comments (2)

Collapse
 
arizona profile image
Arizona

Nice working

Collapse
 
omerjahangir profile image
Omer Qureshi

Thanks for share