I wrote this code:
function get_feed(){
// Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://dorar.shamekh.ws/?feed=rss2');
$maxitems = 1;
$items = array_slice($rss->items, 0, $maxitems,false);
return $items;
}
As a part of a plugin for WordPress , it works fine on my local server , but when I upload it to my blog I get the message:
Warning: array_slice()
[function.array-slice]: The first
argument should be an array in
php version on my local host : 5.2.6
php version on my site : 5.2.5
It seems from the documentation that
$rss->items
should already be an array. I’d guess that the RSS fetch is failing. Try:MagpieRSS combined with dorar.shamekh.ws’ (use of/configuration of) Apache 1.3.41 is leading to a very bizarre behaviour:
A “normal” HTTP request:
MagpieRSS’s request:
Note the different ‘Host’ headers. When the port number is appended, as in MagpieRSS, the site returns a 301:
What about casting $rss->items as an array first:
It sounds like to me that when it is attempting to get the RSS it is failing. Perhaps
fetch_rss
uses file_get_contents which has been disabled for URLs.Either that, or for some reason, the property $rss->items isn’t an array for some reason.
fetch_rss()
it’s deprecated. See: http://codex.wordpress.org/Function_Reference/fetch_rssYou must use
fetch_feed()