• I’m looking for a plugin which it will show the latest categories created, anyone knows something similar?

    THank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’ll write some code for it

    Here you go. It is just some code for now, you can stick it in your theme files somewhere. I will probably turn it into a plugin as well soon.

    Since categories do not really have a creation date, it sorts by their ID, which has the same effect. Just set $num_cats to choose how many to display, and you can customize the output generation – it is currently just displaying a list.

    <?php
    
    global $wpdb;
    $tp = $wpdb->prefix;
    
    $num_cats = 5;
    
    $cats = (array)$wpdb->get_results("
    	SELECT {$tp}terms.term_id as id, {$tp}terms.name as name
    	FROM {$tp}terms, {$tp}term_taxonomy
    	WHERE {$tp}terms.term_id = {$tp}term_taxonomy.term_id
    	AND {$tp}term_taxonomy.taxonomy = 'category'
    	ORDER BY {$tp}terms.term_id DESC
    	LIMIT $num_cats
    "); 
    
    if (count($cats > 0)) {
    	echo '<p>Last ' . $num_cats . ' categories created:</p>';
    	echo '<ul>';
    	foreach ($cats as $c) {
    		echo '<li><a href="' . get_category_link($c->id) . '">' . htmlspecialchars($c->name) . '</a></li>';
    	}
    	echo '</ul>';
    }
    
    ?>
    Thread Starter jorge05r

    (@jorge05r)

    Thanks Dagon Design, I will try it and see if it works ??

    Appreciate your help!

    Let me know how it goes ??

    Thread Starter jorge05r

    (@jorge05r)

    Thanks Dagon Design, the code was fine. It worked just the way I wanted it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Looking for plugin: Show latest categories’ is closed to new replies.