the_category()
uses get_the_category_list()
to do its work, but this function gives you no way to specify classes. However, you can filter the output with the the_category
hook. Since you know the format of the current category links, you can so a search and replace on them.
It would look something like this (untested):
add_filter('the_category', 'highlight_current_cats', 10, 3);
function highlight_current_cats($thelist, $separator, $parents)
{
// The current cat links will look like <a href="https://wordpress.stackexchange.com/questions/2935/[category link]" [other stuff]
// We want them it look like <a href="https://wordpress.stackexchange.com/questions/2935/[category link]" class="current-cat" [other stuff]
$current_cats = get_the_category();
if ($current_cats) {
foreach ($current_cats as $cat) {
$cat_link = get_category_link($cat->term_id);
$thelist = str_replace('<a href="' . $cat_link . '"', '<a href="' . $cat_link . '" class="current-cat"', $thelist);
}
}
return $thelist;
}