Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp rss

This page redirects to an external site: https://developer.wordpress.org/reference/functions/wp_rss

Description

Retrieves an RSS feed and parses it, then displays it as an unordered list of links. 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

<code style="color: #000000"><span style="color: #0000BB"><?php
</span><span style="color: #007700">include_once(</span><span style="color: #0000BB">ABSPATH </span><span style="color: #007700">. </span><span style="color: #0000BB">WPINC </span><span style="color: #007700">. </span><span style="color: #DD0000">'/rss.php'</span><span style="color: #007700">);
</span><span style="color: #0000BB">wp_rss</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">, </span><span style="color: #0000BB">$num</span><span style="color: #007700">);
</span><span style="color: #0000BB">?></span></code>

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) (required) The number of items to display.
Default: None

Output

The output will look like the following:

<code style="color: #000000"><ul>
<li>
<a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'>TITLE FROM FEED</a>
</li>
(repeat for number of links specified)
</ul></code>

Example

To get and display a list of 5 links from an existing RSS feed:

<code style="color: #000000"><span style="color: #0000BB"><?php 
</span><span style="color: #007700">include_once(</span><span style="color: #0000BB">ABSPATH </span><span style="color: #007700">. </span><span style="color: #0000BB">WPINC </span><span style="color: #007700">. </span><span style="color: #DD0000">'/rss.php'</span><span style="color: #007700">);
</span><span style="color: #0000BB">wp_rss</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/rss/feed/goes/here'</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">);
</span><span style="color: #0000BB">?></span></code>

Related

fetch_rss, get_rss

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