Advertisements

get_rss

Definition:
function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS

Display RSS items in HTML list items.
You have to specify which HTML list you want, either ordered or unordered before using the function. You also have to specify how many items you wish to display. You can’t display all of them like you can with wp_rss() function.

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.

Return values

returns:False on failure.

Source code

function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS

	$rss = fetch_rss($url);

	if ( $rss ) {

		$rss->items = array_slice($rss->items, 0, $num_items);

		foreach ( (array) $rss->items as $item ) {

			echo "<li>\n";

			echo "<a href='$item[link]' title='$item[description]'>";

			echo esc_html($item['title']);

			echo "</a><br />\n";

			echo "</li>\n";

		}

	} else {

		return false;

	}

}

1663

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: