This is an old version of this answer!
Return to the current answerI can't take credit for the code (see: Last Updated Categories WordPress 2.3 Query from Devlounge )
but:
but:
<?php
function getLastFiveCats() {
global $wpdb;
$query = "select t.term_id as term_ids, t.name, t.slug, max(p.ID) as id, tx.count from $wpdb->terms t, $wpdb->term_taxonomy tx, $wpdb->term_relationships tr, $wpdb->posts p where t.term_id = tx.term_id and tx.taxonomy = 'category' and tr.term_taxonomy_id = t.term_id and tr.object_id = id and p.post_status = 'publish' group by term_ids order by id desc limit 5";
$results = $wpdb->get_results($query);
foreach ($results as $result) {
$catPermalink = get_bloginfo('url') . "/category/" . $result->slug . "/";
?>
<li><a href='<?php echo $catPermalink ?>'><?php echo $result->name ?></a></li>
<?php
}
}
?>
Tom Ransom | 01/02/10 at 12:10pm





