Created
May 14, 2010 06:03
-
-
Save rmccue/400864 to your computer and use it in GitHub Desktop.
Sort items by title instead of date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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