Add span to archive post count Add span to archive post count wordpress wordpress

Add span to archive post count


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.