Today when I need to add icons to wp_list_categories, the post from Isabel Castillo showed up in the Google search results, which gave me the idea that
wp_list_categories filter could do the magic.
The only problem is for some reason, I need the icon displayed in the
a tag, the pattern from Castillo’s post didn’t work for me.
I’m really suck at Regular Expression, it took me some time to figure it out:
$pattern means “find the start
a tag for me”, and the
$1 in the $replacement means “leave the
a tag you found here”, so we could append the icon (css with background image / web font, or simply a gif / png).