In Many RSS feed we always see the images are showing. We can put the featured image in wordpress rss feed. WP RSS feeds are very important for SEO purpose. If you show the featured image on RSS feed then that will be great.

wordpress add featured image to rss feed

You need to open the functions.php file and put following code in that file. Then if you check your rss feed then RSS feed will be showing the featured images in RSS feed.

function thumbnail_in_rssfeed($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<div style="float:left;">' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'thumbnail_in_rssfeed');
add_filter('the_content_feed', 'thumbnail_in_rssfeed');

This code will show the featured images in content and excerpt RSS feed.

Written by Purab

My name is Purab, Here is my Personal Blog: wpapi.com. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

This article has 3 comments

  1. Sean Delmoral Reply

    Very nice post and straight to the point. I am not sure if this is in fact the best place to ask but do you people have any ideea where to employ some professional writers? Thx 🙂

  2. Harry Reply

    10x for sharing this code. But if my theme use custom post type – listing in my case, will i must to change something in your code to work?
    For example:
    global $post;
    if(has_post_thumbnail($post->ID)) {

    with
    global $listing;
    if(has_post_thumbnail($listing->ID)) {

    Can you tell me if i am wrong?

Leave a Comment

Your email address will not be published. Required fields are marked *