Welcome to WebmasterWorld Guest from

Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Add class to category Wordpress

wordpress add class



7:28 pm on Apr 16, 2012 (gmt 0)

5+ Year Member

I want to add a class to my css if a category is displayed but I can't get it to work.

I added this to my header:

<?php if ( is_category('areas')) { echo ' class="myclass" '; } ?>>

I want to add this class to my stylesheet to any page in this category so It changes the look of any page in that category. It isn't working though.

Ive read through a lot of the codex and this is all I can figure to do

Any suggestions?


7:30 pm on Apr 16, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

is_category only works for the category level page itself. Use in_category for anything within that category so:

is_category('areas') || in_category('areas')


11:31 pm on Apr 16, 2012 (gmt 0)

5+ Year Member

Thank you so much that is exactly what I needed.

Featured Threads

Hot Threads This Week

Hot Threads This Month