28 Oct 2005 02:08
RE: Highlight current category...
>From: Amanzimtoti <amanzimtoti@...> > > >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');(Continue reading)
RSS Feed