Wordpress 如何在标题中添加css
嗨,我不能在类别标题函数中添加CSS类名。如何在下面的函数中添加类名:Wordpress 如何在标题中添加css,wordpress,wordpress-theming,Wordpress,Wordpress Theming,嗨,我不能在类别标题函数中添加CSS类名。如何在下面的函数中添加类名: <?php the_category(', '); ?> //function return array of category //类别的函数返回数组 您必须覆盖模板中已有的功能 您可以使用_类别过滤器钩住回调函数,如下所示: add_filter('the_category','add_class_to_category',10,3); function add_class_to_category(
<?php the_category(', '); ?> //function return array of category
//类别的函数返回数组
您必须覆盖模板中已有的功能
您可以使用_类别过滤器钩住回调函数,如下所示:
add_filter('the_category','add_class_to_category',10,3);
function add_class_to_category( $thelist, $separator, $parents){
$class_to_add = 'category-class';
return str_replace('<a href="', '<a class="' . $class_to_add . '" href="', $thelist);
}
add_filter('the_category','add_class_to_category',10,3);
函数将类添加到类别($thelist、$separator、$parents){
$class_to_add='category class';
return str_replace('先生,如何在这个编码中添加css类?'您可以添加需要更改的图像吗?实际上,我想将css添加到()中,以便按数组进行更改。是否可能?类别没有这样的参数?您是否尝试了上述操作?添加了一个标记。添加一些细节,使问题更容易理解。