WordPress RSS Feed不是PHP文件中的函数


WordPress RSS Feed is not functions in a PHP file

我正在使用一个名为WP- RSS提要的插件。碰巧的是,根据他们的网站,您可以直接在PHP模板中使用RSS提要。当我将以下代码放入模板时,它不会触发,但我得到一个错误,上面写着:"警告:strpos()期望参数1是字符串,数组在/nas/wp/www/staging/sfhr/wp-includes/SimplePie/Content/Type/Sniffer.php第97行"

<?php echo do_shortcode(RSSImport(5,"http://www.indystar.com/apps/pbcs.dll/section?Category=SPORTS0107&template=rss"));
 ?> 

第97行代码如下:

if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
        {
            $official = substr($this->file->headers['content-type'], 0, $pos);
        }
        else
        {
            $official = $this->file->headers['content-type'];
        }

知道为什么我得到这些错误吗?

如果您正在使用插件RSS-Import

http://wordpress.org/extend/plugins/rss-import/

,然后根据文档,你可以把它添加到你的模板文件中:

<?php RSSImport(10, 'http://bueltge.de/feed/'); ?>

如果你想使用do_shortcode(),那么你可以试试这个:

<?php 
  echo do_shortcode('[RSSImport display="5" feedurl="http://bueltge.de/feed/"]');
?>

你也可以使用Wordpress的fetch_feed():

功能来获取RSS提要。
<?php $feed = fetch_feed( $uri ); ?>

此函数使用SimplePie包并自动缓存提要。您可以在法典中阅读更多内容:

http://codex.wordpress.org/Function_Reference/fetch_feed