Advertisements

wp_rss

Definition:
function wp_rss( $url, $num_items = -1 ) {}

Display all RSS items in a HTML ordered list.

Parameters

  • string $url: URL of feed to display. Will not auto sense feed URL.
  • int $num_items: Optional. Number of items to display, default is all.

Source code

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.' );

	}

}

4069

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: