WordPress:Function Reference/get rss

来自站长百科
Xxf3325讨论 | 贡献2008年7月19日 (六) 14:57的版本 (新页面: ==Description== Retrieves an RSS feed and parses it, then displays it as a list of links. The get_rss() function only outputs the list items, not the surrounding list tags itself. Uses ...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

Retrieves an RSS feed and parses it, then displays it as a list of links. The get_rss() function only outputs the list items, not the surrounding list tags itself.

Uses the MagpieRSS and RSSCache functions for parsing and automatic caching and the Snoopy HTTP client for the actual retrieval.

Note

A bug in 2.06 prevents this function from working correctly. This bug will likely be fixed in 2.07 or 2.08.

Usage

%%%<?php require_once(ABSPATH . WPINC . '/rss-functions.php'); get_rss($uri, $num = 5); ?> %%%

Example

The get_rss() function only outputs the list items, not the surrounding list tags itself. So, to get and display an ordered list of 5 links from an existing RSS feed:

%%%<?php require_once(ABSPATH . WPINC . '/rss-functions.php');

echo '

    '; get_rss('http://example.com/rss/feed/goes/here'); echo '

';

?> %%%

Parameters

WordPress:Category:Functions

Output

The output from the above example will look like the following:

%%%

  1. <a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'>TITLE FROM FEED</a>
  2. (repeat for number of links specified)

%%%

Further reading