In WordPress you can add a span to the wp_list_categories()
function with something like:
function style_the_list_count($links) {
$links = str_replace('</a> (', '</a> <span class="listCount">(', $links);
$links = str_replace(')', ')</span>', $links);
return $links;
}
add_filter('wp_list_categories', 'style_the_list_count');
but I want to target the Archive's Show post counts
but after looking for the function to tie into I've been unable to locate what should be used. I've tried wp_get_archives
from my searches but no luck and when I looked under the post Creating an Archive Index I didn't see anything mentioned. Is there a way I can hook into the Archive count or a way I can add a span tag to every instance of a widget's checked Show post counts
for all of the default widgets?
wp_get_archives()
itself doesn't have any useful filters we can hook in to, but get_archives_link()
(which it calls and passes the post count output to) does.
You can use an almost identical function and hook it to the get_archives_link
filter:
function so_40551791_style_the_archive_count($links) {
$links = str_replace('</a> (', '</a> <span class="archiveCount">(', $links);
$links = str_replace(')', ')</span>', $links);
return $links;
}
add_filter('get_archives_link', 'so_40551791_style_the_archive_count');
Note, the
where there was a space before.