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 have a simple Navigation: Blog, About, Contact. Mainsite is Blog. To keep the current Button highlighted, I used this in my CSS:

    li.current_page_item a{
   border-bottom: 1px solid #212121;
    padding-bottom: 1px; 
}

It works pretty fine. But I want to keep Blog still active while I’m listing an item from my categories. What is the best way to do this?

share|improve this question
    
I guess you're willig to keep the button home active also on the category archive page. –  amit Aug 13 '12 at 13:02
    
Yes, but how can I do this in a simple way? –  Nitzki Aug 13 '12 at 13:05
add comment

1 Answer

up vote 2 down vote accepted

Okay, I did it this way::

add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
     if(is_category() && $item->title == "Blog"){ //Notice you can change the conditional from is_single() and $item->title
             $classes[] = "special-class";
     }
     return $classes;
}
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.