[wp-testers] Highlight current category...
Austin Matzko
ajmatzko at hotmail.com
Fri Oct 28 00:08:52 GMT 2005
>From: Amanzimtoti <amanzimtoti at gmail.com>
>
>
>I edited the list_cats() function slightly - I found this line (line 340 on
>the current nighltly build):
>
>$link = '<a href="'.get_category_link($category->cat_ID).'" ';
>
>and I changed it to this:
>
>if ( $category->cat_name == single_cat_title('', FALSE)) {
>$link = '<a href="'.get_category_link($category->cat_ID).'"
>class="current-cat" ';
>} else {
>$link = '<a href="'.get_category_link($category->cat_ID).'" ';
>}
>
Good idea! I turned it into a little plugin that I think does the same
thing:
function wp_current_category_class_attribute ($thelist) {
if (!('' == single_cat_title('', FALSE))) {
$category = single_cat_title('', FALSE);
$string = '/(<a href.*)(>.*' . $category . ')/';
return preg_replace("$string"," $1 class=\"current-cat\" $2",$thelist);
}
else return $thelist;
}
add_filter('list_cats','wp_current_category_class_attribute');
More information about the wp-testers
mailing list