homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

Add class to category Wordpress
wordpress add class

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

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)

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)

Thank you so much that is exactly what I needed.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved