[wp-testers] Highlight current category...

Amanzimtoti amanzimtoti at gmail.com
Thu Oct 27 21:55:19 GMT 2005


I'm not really a php coder, but I recently made a change to the list_cats
function within the wp-includes/templates-functions-category.php file which
enables the current category to be highlighted if you're on a category page.
I noticed that this was one of the features requests on the 1.6 codex page
so thought that you guys may be interested in this. If there's a more
elegant way to do this, please let me know.

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).'" ';
}

Now you can style the current category by specifying the 'current-cat' class
in your stylesheet.

For a demo, you can look at my site
stuart.amanzi.co.nz<http://stuart.amanzi.co.nz>or my dev site which is
test.amanzi.co.nz <http://test.amanzi.co.nz>

Cheers - Stuart.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://comox.textdrive.com/pipermail/wp-testers/attachments/20051027/4436c69e/attachment.htm


More information about the wp-testers mailing list