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

Function Reference/fetch 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.


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.

Deprecated note: Switch to using fetch_feed instead.


include_once(ABSPATH WPINC '/rss.php');
$rss fetch_rss($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: Nonerray.


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

<h2><?php _e('Headlines from AP News'); ?></h2>
<?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->items0$maxitems);

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

Change Log

Source File

fetch_rss is defined in wp-includes/rss.php.


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