WordPress:Function Reference/fetch rss

来自站长百科
Fludlen讨论 | 贡献2008年7月21日 (一) 10:51的版本
跳转至: 导航、​ 搜索

Description

描述

Retrieves an RSS feed and parses it. Uses the MagpieRSS and RSSCache functions for parsing and automatic caching and the Snoopy HTTP client for the actual retrieval.

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

Usage

用法

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

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

Example

例子

To get and display a list of links for an existing RSS feed, limiting the selection to the most recent 5 items:

要得到并且显示当前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; ?>

%%%




%%%

<?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; ?>

%%%


Parameters

参数

rray.

rray.

Related

相关的

wp_rss wp_rss