I’d make it a bit more generic myself. On the home page, I’d highlight the home one, of course. On the category archives, I’d highlight the category. But I’d also want to highlight all the relevant categories on the single pages, handling multiple categories if needed. I’d also want the category list to be dynamic, because manually editing stuff is such a pain.
So here’s my solution (untested, probably has a bug or two):
function display_category_list ()
{
global $wpdb;
$query = "SELECT cat_ID, cat_name
FROM $wpdb->categories
ORDER BY cat_name asc";
$categories = $wpdb->get_results($query);
if (is_category()) {
?>
<style type="text/css">
#navlist li#<?php echo 'cat_'.single_cat_title(); ?> {
color: black;
background-color: gray;
text-decoration: none;
}
</style>
<?php
}
if (is_home()) {
?>
<style type="text/css">
#navlist li#cat_home {
color: black;
background-color: gray;
text-decoration: none;
}
</style>
<?php
}
if (is_single()) {
foreach($categories as $category) {
if (in_category()) {
?>
<style type="text/css">
#navlist li#cat_<?php echo $category->cat_name; ?> {
color: black;
background-color: gray;
text-decoration: none;
}
</style>
<?php
}
}
}
?>
<div id="navcontainer">
<ul id="navlist">
<li id="cat_home">
<a href="<?php echo get_settings('home'); ?>">
Home
</a>
</li>
<?php
foreach ($categories as $category) {
echo '<li id="cat_'.$category->cat_name.'">';
echo '<a href="'.get_category_link($category->cat_ID).'">';
echo $category->cat_name;
echo '</a></li>';
}
?>
</ul>
</div>
<?php
}
?>
Then just call display_category_list() wherever you want to put the list at.