wordpress add featured image to rss feed

wordpress add featured image to rss feed

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.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

3 thoughts on “wordpress add featured image to rss feed”

  1. 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. 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 Reply

Your email address will not be published.