Some folks don’t realize it, but WordPress has integrated the ability to publish other feeds with some out of the box features. I’ve written in the past on how to publish a blog’s feed to give a boost to a site’s keyword density for improved search engine optimization – but this is how to do it right within WordPress.
WordPress has embedded Magpie and RSS Caching within its available functions:
- fetch_rss — retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
- wp_rss — retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
- get_rss — retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
IMO, the first method is the most useful because of the automatic caching. If you’d like to, for example, add a
>h2>>?php _e('Social Media Events'); ?>>/h2>
>?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://eventful.com/rss/events/?q=%22social%20media%22&location_type=&location_id=&l=Worldwide');
$maxitems = 5;
$items = array_slice($rss->items, 0, $maxitems);
?>
>ul>
>?php if (empty($items)) echo '>li>No items>/li>';
else
foreach ( $items as $item ) : ?>
>li>>a href=">?php echo $item["link']; ?>'
title='>?php echo $item['title']; ?>'>
>?php echo $item['title']; ?>
>/a>>/li>
>?php endforeach; ?>
>/ul>
Edit your WordPress template (Design > Theme Editor) and place the code above in your sidebar or on an events page. That’s it – now you have a live feed of events in your sidebar that you never have to update! This can really come in handy. I’ve done just that at I Choose Indy!, where I’ve published the Event feed from Smaller Indiana.
For more advanced users, you can put this in your single page theme and, perhaps, enter a search term as a Custom Field to add other bloggers’ posts on the same topics.