我正在通过显示帖子的类别the_category ();, 我想自定义文本,例如更改颜色、字体大小。。。
这是我的代码:
<span class="post_info"><?php the_category (\', \'); ?> </span>
此代码仅打印
<a> 标记,无类,无ID。
我查了the_category 和get_the_category 关于添加类的内容,但没有发现任何内容。
那么,我如何才能添加class 到该元素
如何添加类以显示类别?
----------------------------------UPDATE ------------------------------
此代码使我想要:
function add_class_to_category( $thelist, $separator, $parents){
    $class_to_add = \'custom-slug\';
    return str_replace(\'<a href="\',  \'<a class="\'. $class_to_add. \'" href="\', $thelist);
}
add_filter(\'the_category\', __NAMESPACE__ . \'\\\\add_class_to_category\',10,3);