How to display a list of categories with description in a widget

Here is how to make your own widget in order to display the categories with their icons and descriptions, based on this article :

1. The script

Add this in the functions.php file of your theme :

add_filter('widget_text', 'do_shortcode');
add_shortcode('caticons_listing','bm_caticons_listing');
function bm_caticons_listing() {
    $listing_code = '<ul>';
    foreach(get_categories("orderby=name&order=ASC") as $category) {
       $link = '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
       $listing_code .= '<li>'.get_cat_icon("echo=false&cat=".$category->cat_ID).' '.$category->description.' '.$link.'</li>';
    }
    $listing_code .= '</ul>';
    return $listing_code;
}

2. The widget

Add a text widget and put the short code in it :

[caticons_listing]

That’s it !