wordpressrssfeedfeedburner

How to show thumnail picture/featured picture of the post in excerpt feed


So I'm using feedburner for my feeds and using that option to only show excerpt/summary of the blog posts, the only problem is that with this option and not the full posts into the feed, it won't show me the images, the featured images of that post.

Is there a way I can do that?

Thank you


Solution

  • You can use the following sample code in the functions.php to show featured image in the excerpt feed

    //Function to add featured image in RSS feeds
    function featured_image_in_rss($content){
        global $post;
        if (has_post_thumbnail($post->ID)){
            $content = '<div class="featured_image_post_rss">' . get_the_post_thumbnail($post->ID, 'medium', array('style' => 'margin:10px; text-align: center;')) . '</div>' . $content;
        }
        return $content;
    }
    
    //Add the filter for RSS feeds Excerpt
    add_filter('the_excerpt_rss', 'featured_image_in_rss');
    

    Also if you want to add featured image to the content feed, just add the following filter in addition with the above code.

    //Add the filter for RSS feed content
    add_filter('the_content_feed', 'featured_image_in_rss');