wp_rss()
Display all RSS items in a HTML ordered list.
No Hooks.
Return
null
. Nothing (null).
Usage
wp_rss( $url, $num_items );
- $url(string) (required)
- URL of feed to display. Will not auto sense feed URL.
- $num_items(int)
- Number of items to display.
Default: all
Notes
- Package: External
- Subpackage: MagpieRSS
Changelog
Since 1.5.0 | Introduced. |
wp_rss() wp rss code WP 6.6.2
function wp_rss( $url, $num_items = -1 ) { if ( $rss = fetch_rss( $url ) ) { echo '<ul>'; if ( $num_items !== -1 ) { $rss->items = array_slice( $rss->items, 0, $num_items ); } foreach ( (array) $rss->items as $item ) { printf( '<li><a href="%1$s" title="%2$s">%3$s</a></li>', esc_url( $item['link'] ), esc_attr( strip_tags( $item['description'] ) ), esc_html( $item['title'] ) ); } echo '</ul>'; } else { _e( 'An error has occurred, which probably means the feed is down. Try again later.' ); } }