Long time without updates : lot of work and family stuff… But let’s come back to the list. Here is an example of how to do that :
echo '<ul>';
foreach(get_categories("orderby=name&order=ASC") as $category) {
echo '<li>'.$category->cat_name.' '.get_cat_icon("echo=false&cat=".$category->cat_ID).'</li>';
}
echo '</ul>';
Update : As I’ve received e-mails and comments on how to implement it, here is the solution. First, create a new page and put {#caticons_listing} in it. Then, paste the following code in the function.php file of your theme (if the file does not exist, create one) :
add_filter('the_content','bm_caticons_listing');
function bm_caticons_listing($content) {
$listing_code = '<ul>';
foreach(get_categories("orderby=name&order=ASC") as $category) {
$listing_code .= '<li>'.$category->cat_name.' '.get_cat_icon("echo=false&cat=".$category->cat_ID).'</li>';
}
$listing_code .= '</ul>';
return str_replace('{#caticons_listing}',$listing_code, $content);
}
Update 2 : You can use a shortcode : [caticons_listing], instead of {#caticons_listing}, which results in a simpler code, as suggested by Robert of trupela.com (thanks, Rob !) :
add_shortcode('caticons_listing','bm_caticons_listing');
function bm_caticons_listing() {
$listing_code = '<ul>';
foreach(get_categories("orderby=name&order=ASC") as $category) {
$listing_code .= '<li>'.$category->cat_name.' '.get_cat_icon("echo=false&cat=".$category->cat_ID).'</li>';
}
$listing_code .= '</ul>';
return $listing_code;
}
See a demo here : http://www.trupela.com/2009/11/16/a-post-is-a-category-is-a-story/