将此代码添加到函数中。php文件,它将删除括号,并用一个带有类的span将post count包围起来,以便轻松设置样式。
function categories_postcount_filter ($variable) {
$variable = str_replace(\'(\', \'<span class="post_count"> \', $variable);
$variable = str_replace(\')\', \' </span>\', $variable);
return $variable;
}
add_filter(\'wp_list_categories\',\'categories_postcount_filter\');
++Bonus在存档小部件中,如果选中“显示帖子数量”复选框,您将看到帖子数量周围有相同的括号,这里有另一个过滤器可以删除它们并添加一个类来轻松设置主题样式。
function archive_postcount_filter ($variable) {
$variable = str_replace(\'(\', \' \', $variable);
$variable = str_replace(\')\', \' \', $variable);
return $variable;
}
add_filter(\'get_archives_link\', \'archive_postcount_filter\');