<h1><?php the_category(' • '); ?> » <a href="https://wordpress.stackexchange.com/questions/90310/<?php the_permalink(); ?>" class="my-title-class"><?php the_title(); ?></a></h1>
How to add class="my-category-class"
to the links, produces by the_category
function?
3 Answers
You can use the_category
filter to hook a callback function like this:
add_filter('the_category','add_class_to_category',10,3);
function add_class_to_category( $thelist, $separator, $parents){
$class_to_add = 'my-category-class';
return str_replace('<a href="', '<a class="' . $class_to_add . '" href="', $thelist);
}