Override core widget output in WordPress
⚠️ This content was imported from a previous incarnation of this blog, and may contain formatting errors
Another snippet for the WordPress theme developers out there. I decided that the category widget didn't display the post count in a very nice-looking way. So I found a nice support post that demonstrates the user of add_filter() to alter output of the category widget. Not the most ideal way to do things in my opinion, but it does the job.
add_filter('wp_list_categories', 'cat_count_span_inline');
function cat_count_span_inline($output) {
$output = str_replace(' (','',$output);
$output = str_replace(')','',$output);
return $output;
}
Via wordpress.org