I was looking at alltop.com the other day. It’s a website that displays all the top headlines from many popular websites. You can see an example below, where I pulled the top 5 headlines from the New York Times.
[rss feed="http://feeds.nytimes.com/nyt/rss/HomePage" num="5"]
This list will change dynamically, as the headlines at the New York Times change. If you click on the link you’ll be taken to the original article. How did I do this?
How to Create the RSS Feed Retrieval Function
//This code is needed to use the wp_rss() function.
include_once(ABSPATH.WPINC.’/rss.php’);
function readRss($atts) {
ob_start();
extract(shortcode_atts(array(
“feed” => ‘http://’,
“num” => ’1′,
), $atts));
wp_rss($feed, $num);
$output_string=ob_get_contents();
ob_end_clean();
return $output_string;
}
add_shortcode(‘rss’, ‘readRss’);
Get Some RSS Feed Addresses
You now have to find an RSS Feed URL that you’d like to display. You can find tons of feeds here Bloglines. Here are some of the most popular feeds:
How to Display Your Feed Links
To paste links to Yahoo’s top 5 entertainment feed link’s, I would just cut an paste this line of text:
rss feed=”http://rss.news.yahoo.com/rss/entertainment” num=”5″]
You could link to any other RSS feed by changing the value of feed. You could also change the number of links shown by changing the value of num. It is set to show 5 links in the example above.
WordPress Short Codes
You just created a WordPress Short Code! You use short codes to easily execute PHP code scripts inside of your posts. There are tons of short codes available that:
If you’d like me to talk more about short codes, leave a comment below.
That’s All Folks
Sorry for the short post today, but I’m working on a bunch of major projects for you of course! You should be very happy with the results. If you have any questions leave them in the comment section below.
Here to Serve
Think Tank