homepage Welcome to WebmasterWorld Guest from 54.83.133.189
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

    
Add class to category Wordpress
wordpress add class
roclimb




msg:4441621
 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?
Rob

 

lorax




msg:4441623
 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')

roclimb




msg:4441712
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved