Add Twitter Bootstrap Glyphicons to individual list items in wp_list_categories. Do this by modifying the wp_list_categories. Easy peasy by adding a filter. No forsaken Walker needed. My example below adds the ‘icon-book’ glyphicon to each list item generated by wp_list_categories. For all the possible icons you can choose from, see the Twitter Bootstrap stylesheet (bootstrap.css).
/**
* add glyphicons to wp_list_categories 'id="icon-book"
*/
function isa_add_icons_wp_list_cats($wp_list_categories) {
$pattern = '/<a/';
$replacement = '<i class="icon-book"></i><a';
return preg_replace($pattern, $replacement, $wp_list_categories);
}
add_filter('wp_list_categories','isa_add_icons_wp_list_cats');
Tom
October 27th, 2013 at 4:31 pm
Cheers for that 🙂
ratm
October 24th, 2012 at 1:18 pm
How can I apply this for deppend ID categories?