/*
* Add spans around category counters
*/
function _thz_filter_wp_list_categories($output, $args) {
if($args['show_count']){
$re = '/<\/a>(.*?)<\/li>/s';
preg_match_all($re, $output, $matches);
if(!empty($matches) && isset($matches[1])){
foreach($matches[1] as $between){
$between = strip_tags($between);
$output = str_replace($between,'<span class="count">'.$between.'</span>',$output);
}
}
}
return $output;
}
add_filter( 'wp_list_categories', '_thz_filter_wp_list_categories',10,2 );
/*
* Add spans around archive counters
*/
function _thz_filter_get_archives_link( $output ) {
$re = '/<\/a>(.*?)<\/li>/s';
preg_match_all($re, $output, $matches);
if(!empty($matches) && isset($matches[1])){
foreach($matches[1] as $between){
$between = strip_tags($between);
$output = str_replace($between,'<span class="count">'.$between.'</span>',$output);
}
}
return $output;
};
add_filter( 'get_archives_link', '_thz_filter_get_archives_link', 10, 6 );