Is there a way to draw the categories listing and highlight the current category being viewed?

In addition, it would be great to highlight the current category if a post or page that's assigned to it is being viewed.

Any help much appreciated...

Here's my current code (I'm excluding the default "uncategorized" category)...

  echo "<div class='menu top'><ul>";
    $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
    $cat_args['title_li'] = '';
    $cat_args['exclude_tree'] = 1;
    wp_list_categories(apply_filters('widget_categories_args', $cat_args));
  echo "</ul></div>";
  • Hey @Scott B: I see you'd only accepted 1 of 4 answers. Just a tip, if you find someone's answer to your question is good please do mark it as the best answer and give a vote up to anyone else who provides good input. That'll bump up their reputation and given them some recognition for their efforts. Aug 25, 2010 at 22:39
  • Thanks, I just started posting questions a few days ago. I'm evaluating the answers. It does not mean an answer won't be selected once I have more time to review them.
    – Scott B
    Aug 26, 2010 at 11:41

2 Answers 2


The Wordpress Codex for the wp_list_categories tag is actually pretty helpful here - Wordpress is already assigning a class to the < li > tag of the current category.

At that point you just need to add an entry to your theme's .css file to apply whatever highlighting you want to that class.

For instance:

li.current-cat { 
background: #CCC; }

Should give you a nice grey background.

  • Thanks Chris, I overlooked that. Do you know how to enable current-cat-parent? If such exists.
    – Scott B
    Aug 26, 2010 at 11:42
  • Scott, the Codex implies that the current-cat-parent class should be applied automatically to the category listing, which would mean you could select it in css with li.current-cat-parent { ... } However, I don't have a place immediately at hand to test that out. Aug 26, 2010 at 17:17

My first inclination is that you'd need to somehow apply a different class to the "current" category and then use CSS to highlight it. Hopefully that's a start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.