数字化技能提升教程,数字化时代生存宝典

数字化百科 / 产品文档 / WordPress:Function Reference/fetch rss

WordPress:Function Reference/fetch rss

查看全部产品文档命名空间:WordPress

描述

得到RSS feed并且对其进行解析。使用MagpieRSS and RSSCache函数,为真正的retrieval解析并且自动地储存并且Snoopy HTTP client。

用法

%%% <?php include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss($uri); ?> %%%

例子

要得到并且显示当前RSS feed的链接列表,将选项限制为最近的五个: %%%

<?php _e('Headlines from AP News'); ?>

<?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://example.com/rss/feed/goes/here'); $maxitems = 5; $items = array_slice($rss->items, 0, $maxitems); ?>

    <?php if (empty($items)) echo '
  • No items
  • '; else foreach ( $items as $item ) : ?>
  • <a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'> <?php echo $item['title']; ?> </a>
  • <?php endforeach; ?>

%%%

参数

rray.

相关的

wp_rss