WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/get rss


This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use any of these functions instead.

Contents

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.

Deprecated note: Switch to using fetch_feed instead.

Usage

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

Parameters

$uri
(URI) (required) The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting and useful bits in the items array.
Default: None
$num
(integer) (optional) The number of items to display.
Default: 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 
'<ol>';
get_rss('http://example.com/rss/feed/goes/here');
echo 
'</ol>';
?>

Output

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

<ol>
<li><a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'>TITLE FROM FEED</a><br /></li>
(repeat for number of links specified)
</ol>

Related

See also index of Function Reference and index of Template Tags.