wp_rss

Display all RSS items in a HTML ordered list.

Description

wp_rss( (string) $url, (int) $num_items = -1 ); 

Parameters (2)

0. $url (string)
URL of feed to display. Will not auto sense feed URL.
1. $num_items — Optional. (int) => -1
Number of items to display, default is all.

Usage

  1. if ( !function_exists( 'wp_rss' ) ) { 
  2. require_once ABSPATH . WPINC . '/rss.php'; 
  3.  
  4. // URL of feed to display. Will not auto sense feed URL. 
  5. $url = ''; 
  6.  
  7. // Optional. Number of items to display, default is all. 
  8. $num_items = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_rss($url, $num_items); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/rss.php  
  1. function wp_rss( $url, $num_items = -1 ) { 
  2. if ( $rss = fetch_rss( $url ) ) { 
  3. echo '<ul>'; 
  4.  
  5. if ( $num_items !== -1 ) { 
  6. $rss->items = array_slice( $rss->items, 0, $num_items ); 
  7.  
  8. foreach ( (array) $rss->items as $item ) { 
  9. printf( 
  10. '<li><a href="%1$s" title="%2$s">%3$s</a></li>',  
  11. esc_url( $item['link'] ),  
  12. esc_attr( strip_tags( $item['description'] ) ),  
  13. esc_html( $item['title'] ) 
  14. ); 
  15.  
  16. echo '</ul>'; 
  17. } else { 
  18. _e( 'Anerrorhas occurred, which probably means the feed is down. Try again later.' );