Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何在标题中添加css_Wordpress_Wordpress Theming - Fatal编程技术网

Wordpress 如何在标题中添加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(

嗨,我不能在类别标题函数中添加CSS类名。如何在下面的函数中添加类名:

 <?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添加到()中,以便按数组进行更改。是否可能?类别没有这样的参数?您是否尝试了上述操作?添加了一个标记。添加一些细节,使问题更容易理解。