1

I'm trying to use fetch_feed to pull a feed that is hosted on the same server (but uses a different domain name). So, my site is, for example, bullfrogs.com and I'm trying to pull an RSS feed of events from tadpoles.com, which is hosted on the same server but not in the same WP install and using a different domain name. It doesn't work. It says there are "no items" in the feed.

Now, I can use the exact same fetch_feed function to pull any other validated RSS feed (such as from, say, CNN or Gawker) from an external server into bullfrogs.com. I can also use the same code block on another site of mine on a completely different web host/server, turtles.com, and it will pull the RSS from tadpoles.com with no problems. The RSS feed from tadpoles.com validates with the W3C RSS validator tool.

Assume I don't know much about the server, and that I don't manage it and need to ask a sys admin to help me if the issue is anything that can't be fixed from the WordPress dashboard. He has already reported that he doesn't see anything in the debug stuff or site logs aside from a 500 error on the rss feed. How do I ask about other possibilities, and what things should I be looking for?

The code is from this site and looks like this:

    <?php if(function_exists('fetch_feed')) {

    include_once(ABSPATH . WPINC . '/feed.php');               // include the     required file
    $feed = fetch_feed('http://tadpoles.com/feed'); // specify the source feed

    $limit = $feed->get_item_quantity(7); // specify number of items
    $items = $feed->get_items(0, $limit); // create an array of items

    }
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>

<div>
    <a href="<?php echo $item->get_permalink(); ?>" 
      title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
        <?php echo $item->get_title(); ?>
    </a>
</div>
<div>
    <?php echo substr($item->get_description(), 0, 200); ?> 
    <span>[...]</span>
</div>

<?php endforeach; ?>

Thanks in advance.

0

Sounds like you have a server configuration issue--specifically a problem with loopback.

Sometime servers have trouble making HTTP requests to themselves via a FQDN. This could be caused by a lot of different things, but your best (first) bet is to have your sysadmin ensure that all your domains exist in the server's host file, and refer to whatever local IP each virtualhost is listening on. Like:

127.0.0.1 bullfrogs.com
127.0.0.1 tadpoles.com

This is the most likely thing. But if it doesn't fix things, have you sysadmin explore any other possible complications with loopback and your web server configuration (i.e., can the server make requests to its own sites). This is something the sysadmin should be able to diagnose from the server's CLI using some quick CURL requests.

  • Thank you, this is helpful. Forgive my ignorance, but he's told me that he's done a wget of the tadpoles.com feed from the server without issue. Can you help me assess where that fits in within what you've said? Is Wget a kind of CLI, basically? – bobby May 9 '14 at 18:40
  • Hrm. Ask him to try curl rather than wget and see what the result is. WordPress will try curl, streams, and (possibly) fsockopen for all of its http requests. – MathSmath May 9 '14 at 19:32
  • It turns out that cURL isn't enabled or installed or something like that, which I'm fairly certain is the problem. Thanks again, many months later! – bobby Jul 31 '14 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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