WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 categories, just to make an easy example, Cars and Bikes. I have a post that fits both of the category. If i visit the Cars category, the body_class looks like this:

"archive category category-cars category-1 category-cars category-bikes"

The problem is that somehow the post category is visible in the body_class after the category-1 classname. How can i avoid this? I need to use different colors for different categories, but right now the category-bikes class overwrites the category-cars class.

share|improve this question

This could be solved via CSS as well. Just set up declarations for the special cases where there is overlap between categories:

.category-cars { background-color: #f00; }
.category-cars.category-bikes { background-color: #0f0; }

This will give any posts that are in both bikes and cars the same background color as those used in the bikes category.

share|improve this answer
Yes, but i have 9 categories, so this solution is not exactly what i am looking for. But thanks:) Maybe i just remove the body_class function and add the category slug to the body... – passatgt Jul 25 '12 at 15:32
I just duplicated the get_body_class function to my functions.php, and if i change return apply_filters( 'body_class', $classes, $class ); to return $classes, it works fine. I guess something is using a filter to hook up those extra category classes, but i can't find it anywhere... – passatgt Jul 25 '12 at 16:03

Your Answer


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.