Skip to content

Instantly share code, notes, and snippets.

@rmccue
Created May 14, 2010 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmccue/400864 to your computer and use it in GitHub Desktop.
Save rmccue/400864 to your computer and use it in GitHub Desktop.
Sort items by title instead of date
<?php
require_once('/(path-remove-for-security)/simplepie.inc');
class SimplePie_Title_Sort extends SimplePie {
function sort_items($a, $b)
{
return strlen($a->get_title()) >= strlen($b->get_title());
}
}
header('Content-type:text/html; charset=utf-8');
$feed = new SimplePie_Title_Sort();
$feed->set_feed_url('http://feeds.delicious.com/v2/rss/ibgmedia/domains?count=100');
$feed->enable_order_by_date(false);
$feed->init();
echo '<div class="newsblocksfeed">';
echo '<ul>';
// Limit the items to be shown
$i = 1;
foreach($feed->get_items() as $item){
if($i<100){
echo '<li><a href="'.$item->get_permalink().'" target="_blank">'.$item->get_title().'</a><br />'. "\n";
$i++;
}
}
echo '</ul>';
echo '</div>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment