How to Show Thumbnail for Partial feed in WordPress

IN Shoutmeloud, WordPress

In the past I talked a lot about Partial feed (Summery feed) and why you should have Partial feed. As it is, if you have read why images are important for blog, you would understand that it helps in increasing CTR. Though when you convert your complete feed into Partial feed, you will notice that Feedburner, Google reader, Facebook and other services won’t show any image for post. Specially after implementing partial feed, I noticed that traffic from Facebook went down and it’s because of less CTR due to no thumbnail.

This post is for all those who have implemented Partial feed (Summery feed) and want to show image in the feed. You need to have knowledge of FTP and basic copying-pasting code. If not, you can always take help of our WordPress services. Getting back to tutorial, all we need to do is edit two files from wp-includes folder (feed-rss2.php and functions.php).

Showing Thumbnail on Facebook and Other RSS readers: WordPress

Login to your FTP account and browse to wp-includes folder and download and make a back of above mentioned files in a folder. Now lets start with editing of these files to show thumbnail.

Editing-wp-include

Editing feed-RSS2 file:

Click on open and edit feed-rss2.php file and search for line:

[php]<?php the_excerpt_rss() ?–>[/php]


And add this line before above code and after [CDATA[

[php]<?php echo ‘<img src="’.get_first_image().’" alt="" />’ ?>[/php]

Save the file and upload it back to wp-includes folder.

Editing WordPress functions.php:

Now open Functions.php from Wp-includes folder and search for this line: “Removes site option by name”

And add this code as shown the image:

[php]
function get_first_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\’"]([^\’"]+)[\’"].*>/i’, $post->
post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){
//Defines a default image
$first_img ="http://domain.com/default.jpg";
}
return $first_img;
}[/php]


Don’t forget to replace the http://www.yourdomain.com/default.jpg with your default image link. Save and upload the file back.
Now it will take almost 24 hours for Feed-burner to update your feed or if you use direct feed on Facebook, you will see thumbnail from next published post.

This also makes your feed looks good else after implementing Partial feed you might have noticed less traffic from Feeds or Facebook (Atleast true in my case).

Do let me know if you find any issue implementing thumbnail for partial feed and I will try to answer asap. You can also use our Facebook fan page to ask questions.

Subscribe on Youtube

Click to activate Offer & visit site Discount added automatically

Subscribe to SML Newsletter

Receive Blogging Tips & Strategies

Get WordPress Guide eBook for free in the 2nd newsletter

100% privacy. we will never spam you

  • Author Bio

  • Latest Post

Blog post by Harsh Agrawal

Harsh has written 1050 articles.

Follow ShoutMeLoud on Twitter. Subscribe to ShoutMeLoud feed via RSS or EMAIL to receive instant updates.


Testimonials
Send Us Inquiry

Comments

  1. Manendra says

    Since from a couple of days i am wondering Y my images are not displaying in my FB RSS and thank Q for the tutorial i made the necessary changes as you mentioned above hope i’ll see the thumbnails in coming 24Hrs.

  2. Rajan Balana @ DreamBloggers says

    Hey Harsh, The code shown in the image is not matching with the code shown in the code

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>