How to Add Thumbnails to WordPress RSS Feed


I was developing home page for my theme directory site themeappears. I wanted to display the content thumbnails from the 3 different subdomains(premium wordpress, free blogger, free wordpress) in single page by using SimplePie(Used to read and manipulate RSS feed).

I tried to display the image thumbnails from the RSS feed using SimplePie but i found that we first need to add a bit of code to theme functions to display thumbnails in RSS feed before accessing that thumbnail using SimplePie. Here is one of my RSS feed with thumbnail images.

Below are the steps to display thumbnails in RSS feed:

Step 1 Install Get the Image WordPress Plugin.

This plugin is used to grab the images from the posts by custom fields, WP’s featured image, post attachment or from the post content.

Step 2 Copy and paste the following code to theme functions.php which can be found here: Dashboard -> Appearance -> Editor -> functions.php(Theme Functions file at right hand side). Paste the below code before the closing PHP tag (?>), if not present, just paste it at the end of the file.


function display_post_thumbnail_in_rss($rss_content) {
    global $post;
    if ( function_exists( 'get_the_image' ) ) {
        $rss_content= '<div style="float : left;margin-right:10px;">'.get_the_image(array( 'default_image' => '', ‘image_scan’ => true,  'width' => '150', 'echo' => false ) ). '</div>'.$rss_content;
    }
    return $rss_content;
}
add_filter('the_content_feed', 'display_post_thumbnail_in_rss');

add_filter('the_excerpt_rss', 'display_post_thumbnail_in_rss');

Refresh your RSS feed to see the changes. You can change the width of the image in above code.

I am using Google Chrome browser with RSS extension to read the RSS feed. In Mozilla plugin is already been installed to read the RSS feeds.

Also Read: 6 High Quality Premium WordPress Showcase Themes

Thanks to www.staenzwebsolutions.com

Featured Items - Recommended WordPress and Web Development Books

Want to learn IN and OUT of web development and become professional web developer? Here are the list of WordPress and Web Development books which i recommend you to start with.
FIND OUT MORE

Featured Items - 200+ Popular HTML Email and Newsletter Templates for Effective Marketing

Do you want to market your products effectively ? Do you want to send newsletter to your customer in the way that you want ? Do you want full control over the email design ? There are 200+ great collection of E-mail and Newsletter HTML templates from Themeforest. Get into site directly and search for the suitable template that boost your sales and conversion rate.
FIND OUT MORE

Featured Items - Start Your Own Community Website Like Facebook In a Minute

Want to start your own social or community website like Facebook ? Start right away using Buddypress WordPress plugin along with premium Buddypress Themes. No need to setup anything. It works out of box. Install BuddyPress plugin and Premium themes from this list. Your are done!.
FIND OUT MORE

Featured Items - Unlimited Web Hosting from HostGator 25% OFF

HostGator is a one of the most trusted Easy and Affordable Web Hosting Provider next to Inmotion Hosting. LIMITED TIME OFFER! Get 25% OFF using coupon code: BLOGOSYS25
FIND OUT MORE

Featured Items - Collection of Best Premium Portfolio WordPress themes

Need to showcase your project work in a stunning way? These premium Portfolio WordPress themes will make your work easy for you. Perfect for showcasing Project, Photography, Video and Art work.
FIND OUT MORE

, , , ,