Ah, the mighty RSS feed. Straight from your blog to your subscribers’ readers. There are plenty of plugins for RSS feeds, like FeedWordPress, and WordPress also has a built in RSS widget that can display all sorts of goodies from blogroll feeds.
Maybe you, like me, want to add a page dedicated to an RSS feed. While you could definitely do this with any number of plugins, it’s easier to take advantage of a few native functions. Before you start, familiarize yourself with WordPress’ custom pages.
In another post, I’ll go over using your Blogroll or another link category for the feed. Now, I’ll just cover taking the URL for an RSS feed and generating a list of posts.
$url = “http://notrelated.com/feed”;
$start = 0; // post to start with
$end = 10; // post to end with
$rss = fetch_feed($url); // get the feed
foreach($rss->get_items($start, $end) AS $item) {
$title = $item->get_title(); // post title
$date = $item->get_date(“d.m.Y”); // post date, reference date() for proper inputs
$content = $item->get_content(); // post content
$author = $item->get_author()->get_name(); // post author
// now display is all in HTML
}
The retrieved feed can be displayed just like WordPress posts by using your Loop HTML. To see this in action, visit the demo page. You can also grab the page for your tweaking pleasure.
Feedback