我尝试在正在构建的迷你主题上使用 WP Hooks 样式,但"颜色"属性不起作用。
<span style="color: #C40000; font-family: 'Roboto', sans-serif; font-size:26px; padding: 5px; line-height: 1; text-decoration: underline; -moz-text-decoration-color: #C40000; text-decoration-color: #C40000;">
<?php echo the_category(''); ?>
</span>
使用类别样式添加到 css 文件类
.category-style{
color: #C40000;
font-family: 'Roboto', sans-serif;
font-size:26px;
padding: 5px;
line-height: 1;
text-decoration: underline;
-moz-text-decoration-color: #C40000;
text-decoration-color: #C40000;
}
接下来创建过滤器,您可以将其放置在函数中.php
<?php
add_filter( 'the_category','category_style', 10, 3 );
function category_style( $thelist, $separator, $parents ){
$class_to_add = 'category-style';
return str_replace( '<a href="', '<a class="' . $class_to_add . '" href="', $thelist );
}
?>
和文件中的最后一个显示类别。
<?php echo the_category(''); ?>