Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I needed a category listing in my posts page and I want the current category to be highlighted. I enabled the 'All' category, so consequently, I want the 'All' also to be highlighted when I'm viewing the posts page. So I used the codex and got the following script running.

My script is:

<cat>
<ul>
<?php wp_list_categories('show_option_all=All&hide_empty=0&title_li=&current_category=All'); ?>
</ul>
</cat>

Do I have to run an IF conditional on my archive.php file to get the category ID and highlight it using CSS class 'cat.current-cat'? How do I do it if the category is 'All' since the 'All' doesn't exactly have a category ID?

Thanks!

share|improve this question
add comment

1 Answer 1

Seems that the function outputs the current category with a special class name by default.

http://codex.wordpress.org/Template_Tags/wp_list_categories#Markup_and_Styling_of_Category_Lists

In your CSS you should be able to just do:

li.current-cat { ... }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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