RSS Feeds
MNN Headlines On Your Site
These instructions involve the use of PHP to include MNN headlines on your own web site. If you're not comfortable with PHP, please check our Javascript method.
The easiest way to use PHP to get RSS content on your own web site is with SimplePie. It's a wonderfully powerful PHP class that does all the work of getting the content and preparing it for you. All you have to do is then render it the way you want.
Once you have SimplePie installed, you can use a function similar to this: (note, this assumes you've included the SimplePie class, as their instructions indicate)
// get rss and convert it to an unordered list
function feed2ul($feed_url = "", $end = "5") {
// Initialize new feed
$feed = new SimplePie();
$feed->set_feed_url($feed_url);
$feed->init();
$num = 0;
$output .= '<ul class="feed">' . "\n";
// Loop through all of the items in the feed
foreach ($feed->get_items() as $item) {
if($num < $end) {
$output .= '<li><a href="' . $item->get_link() . '">' . $item->get_title() . '</a></li>' . "\n";
}
$num++;
}
$output .= '</ul>' . "\n";
return $output;
// end feed2ul
}
You just feed it a url, and optionally how many feed items you want, like this:
<?php print feed2ul('http://www.mnnonline.org/rss/pubNewsTease.rdf', '5'); ?>



