what i’m reading
I recently added a new feature to my website. The “My Reads” section to the right contains the latest articles that I found interesting on Google Reader. The articles I most recently shared will show up here. This feature is something I’ve been wanting to add for a while now and I started looking at plugin’s to do the work for me, but then I remembered, “Hey! I’m a developer. I should just do it myself.” A little PHP research let to the quick snippet below explaining a built-in WordPress function that made things super easy. Just plug in my Google Reader sharing feed URL and away we go.
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$feed = fetch_feed('http://www.google.com/reader/shared/nate.jara');
$feed_items = $feed->get_items( 0, $feed->get_item_quantity(5) );
if ( $feed_items ) {
echo "<li><h2>My Reads</h2><ul>";
foreach ( $feed_items as $item ) {
echo "<li><a href='" . $item->get_permalink() . "' title='" . $item->get_title() . "' target='_blank'>" . $item->get_title() . "</a></li>";
}
echo "</ul></li>";
}
?>
