WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a piece of code, which is used to display images on every post from RSS FEEDS, the images will be fetched from yahoo images search,

I will paste this code into my single.php file, so that it will appear after my post, This code I found in one of the website where, this was used for the same reason to fetch images but not from yahoo but from different feeds

The code which I am using is this:-

    include_once(ABSPATH.WPINC.'/rss.php'); // path to include script
    $feed = fetch_rss('http://news.search.yahoo.com/news/rss?p=car'); // 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="niraj" src=" <?php
    $pubdate = substr($item['pubdate'], 0, 16);
    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';}
    echo $a;
    $str= $item['link'];
    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']; ?></a></h4>
    <?php endforeach; ?>
    <?php endif; ?>

I tried this code, but the problem is the images are not coming. If this is not a correct way to fetch images from yahoo search, then is there any appropriate way to do it?

share|improve this question
Is this the actual code you use? Because you combine information from the Yahoo! feed to create path to your upload directory, and then append a part of the Yahoo! feed link to it? If you use a feed from Yahoo! images (and not News, like in your example), I would assume you don't have to prefix the path with your upload directory? – Jan Fabry Jan 21 '11 at 12:27
@Jan Fabry yes you are right, The actual code was to fetch the images from different feed, but the code was for images only, I just changed the feed URL from different to Yahoo images feed How can I make the images display? – ntechi Jan 21 '11 at 12:39
Your question is not very clear. Can you edit it so it includes the actual feed address you want to use, and where the image should come from: from the feed, or from your own server, based on some information in the feed? Maybe with an example where you include the source code for one item in the feed, and the image you want to display with it. – Jan Fabry Jan 21 '11 at 13:18
How you be certain you have a right to display images returned from the yahoo feed? Would there be no question of copyright violation here? – t31os Jan 21 '11 at 15:40
@ t31os I agree with you that its illegal , but I just want to check it, is this possible, cause I am not going to use feed of yahoo search, I am going to use my own another website feed – ntechi Jan 22 '11 at 4:14
up vote 0 down vote accepted

First fetch_rss() is long deprecated, use fetch_feed().

As for images I don't know if that is what you want but you build URL to your own computer by using localhost and there is no way to know what it going on there or what is expected from those links.

share|improve this answer
you mean to say on localhost it wont show any images? – ntechi Jan 21 '11 at 8:06
@ntechi it will show images for links that point to images. I have no idea if those links point to correct images on your local computer. And of course you are the only one who can see local images in any case. – Rarst Jan 21 '11 at 9:09
now I added that to my website, but still no images are coming, I changed from localhost to my website, but previously I was getting broken images icon, now I am getting just the name of that image – ntechi Jan 21 '11 at 9:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.