Author Topic: WordPress Get RSS Feed with Thumbnail Images  (Read 1629 times)

bbasujon

  • Administrator
  • VIP Member
  • *****
  • Posts: 1827
  • I want to show my performance at any where
    • View Profile
    • Higher Education
WordPress Get RSS Feed with Thumbnail Images
« on: January 29, 2012, 07:05:15 AM »
I was recently approached by one of my friend who needed a small help in WordPress. He own two blogs and he wanted to display the feeds of the second blog in the first blog. That was quite easy as there are many plugins, inbuilt within WordPress that can do the job. But he wanted to display the thumbnail images too along with the title.

After a long search I got few plugins, but none of them seemed to work. So finally gave up searching and starting to do something myself. I them figured out a solution to this and could successfully bring the image as well as the post title, as in the below shown image.

How to Get RSS Feeds with Images from other Site

Below listed is a small code that I have used to grab the RSS Feeds with Images from another website in WordPress. The name of the thumbnail image and the post name must match for the image to be grabbed. There are ofcourse methods to get the first image of the post, but I stronger suggest using Custom Field.

<?php
include_once(ABSPATH.WPINC.’/rss.php’); // path to include script
$feed = fetch_rss(‘http://indianmotosblog.com/feed/’); // specify feed url
$items = array_slice($feed->items, 0, 5); // specify first and last item
?>
<?php if (!empty($items)) : ?>
<?php foreach ($items as $item) : ?>
<h4><img id=”rkdperil” src=” <?php
$pubdate = substr($item['pubdate'], 0, 16);
$a=”http://indianmotosblog.com/wp-content/uploads/”;
$a.=substr($pubdate,12,4);
$a.=”/”;
$m=substr($pubdate,8,3);
if($m == “Jan”){$a.=”01″;}
elseif($m == “Feb”){$a.=”02″;}
elseif($m == “Mar”){$a.=”03″;}
elseif($m == “Apr”){$a.=”04″;}
elseif($m == “May”){$a.=”05″;}
elseif($m == “Jun”){$a.=”06″;}
elseif($m == “Jul”){$a.=”07″;}
elseif($m == “Aug”){$a.=”08″;}
elseif($m == “Sep”){$a.=”09″;}
elseif($m == “Oct”){$a.=”10″;}
elseif($m == “Nov”){$a.=”11″;}
else{$a.=”12″;}
$a.=”/”;
echo $a;
$str= $item['link'];
$len=strlen($str);
$test=substr($str,27,($len-1));
echo $test;
?>.jpg” width=”90″ height=”60″ alt=<?php echo $item['title']; ?> style=”border: none;align:left;”/><div style=”clear:both”></div><a href=”<?php echo $item['link']; ?>”><?php echo $item['title']; ?>[/url]</h4>
<?php endforeach; ?>
<?php endif; ?>
Acquire the knowledge and share the knowledge so that knowing,learning then sharing - all are the collection