How to display category icons in the sidebar

To display the icons in the sidebar, you have 2 solutions :

1. Use the widget
Go to Appearance > Widgets and drag Category Icons Widget to the right. You can have multiple Category Icons widgets.

Image 71 How to display category icons in the sidebar

Category Icons Widget

Image 8 How to display category icons in the sidebar

Category Icons Widget Settings

2. Manually

In the sidebar.php page of your WordPress theme, you must use the put_cat_icons function.

UA:F [1.6.2_892]

Function : put_cat_icons()

This function ”iconizes” your categories list in the sidebar.

put_cat_icons(list [,get_cat_icon_parameters] [,'icons_only=true'])

  • list : this is a WordPress category list : wp_list_categories(). You MUST ADD echo=0 to the wp_list_categories parameters.
  • get_cat_icon_parameters : (optional) these are the get_cat_icon() parameters, separated by a ‘&’.
    There’s an exception : for put_cat_icons(), the parameter ‘link’ is always set to false.

Example :

write the following code in sidebar.php to have icon next to the category name for which you uploaded an icon. You can give any parameters to wp_list_categories, but you MUST ADD echo=0, in order to process the list :

if (function_exists('put_cat_icons'))
  put_cat_icons(wp_list_categories('title_li=&echo=0'));
else
  wp_list_categories('title_li=');

In the parameters, if you put : ‘icons_only=true’, then only the icons will be displayed in the sidebar, instead of the icon AND the category name. Look at the 2nd line :

if (function_exists('put_cat_icons'))
put_cat_icons(wp_list_categories('title_li=&echo=0'),'icons_only=true');
else
wp_list_categories('title_li');

If you use the widget, just put icons_only=true in the parameters :

Image 1 Function : put cat icons()

Widget