Wordpress - Problemas con la función fetch_feed

I have been developing a Wordpress site on my local machine and in my custom theme, I implemented an RSS feed parser (using tutorials off the 'net) and it works a charm!

However, I have come to put the site live on a production server and the same code simply doesn't work.

I had copied all my Wordpress files and simply ran the installation again by removing the config file. As I am still testing stuff, it currently sites in a subfolder in the public_html folder (in fact my local installation was also in a subfolder).

Here is the code to get the feed and parse it:

if(function_exists('fetch_feed')) {
    include_once(ABSPATH . WPINC . '/feed.php');
    $feed = fetch_feed('FULL FEED URL HERE');
    $limit = $feed->get_item_quantity(5);
    $items = $feed->get_items(0, 3);
}
if ($limit == 0) {
    echo '<p>The feed is either empty or unavailable.</p>';
} else {
    foreach ($items as $item) :
?>
    <h3>
        <?php echo $item->get_title(); ?><br/>                            
        <small><?php echo $item->get_date('j F Y @ g:i a'); ?></small>
    </h3>  
    <p><?php echo substr($item->get_description(), 0, 140); ?>...</p>
    <p><a href="<?php echo $item->get_permalink(); ?>" title="Read more about <?php echo $item->get_title(); ?>">more</a><p>
<?php
    endforeach;
}
?>

(note I have not included the feed URL as it is sensitive data. I have checked and the feed file works 100%, is fully W3C valid and is set to 755 CHMOD)

Now again, this code works on my local Apache server, but does not work on my live server. the script gets up to the $limit = $feed->get_item_quantity(5); commands and halts, breaking the rest of the web page.

I tried removing it and simply setting the second limit parameter on get_items(); but the script still failed to get past that point.

A friend suggested it could be a cache issue, but I cannot find a cache for the feed function.

¿Alguna idea amigos?

¡Salud

preguntado el 12 de junio de 12 a las 13:06

Esto requiere una depuración básica primero. por favor haz un error_reporting(~0); ini_set('display_errors', 1); al principio de su guión. Además deberías habilitar el registro de errores y siga el registro de errores. -

I did some debugging and I got the feed error: WP HTTP Error: couldn't connect to host. Now this gets even more confusing as on my local machine this works fine, connecting to the same URL of the rss feed. The feed is on the same liver server thats having issues! Argh -

permitir WP_DEBUG as well as this is wordpress (otherwise WP might degrade your logging settings, or it screws it anyway. Let's cross fingers WP_DEBUG helps). Probably that host does not allow you to do remote connections. So good luck and ask the support of your hoster as well. -

I assumed the same about the host not allowing remote connections, but I can use an RSS feed from BBC UK News with no problems! -

Okay, then the problem is, that the DNS server of your hoster does not resolve to own URLs probably. Check with the support, I think they have a little flaw in their setup. Just tell them you want to access your own website via HTTP from within the server as well. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.