Forum Replies Created
-
AuthorPosts
-
February 23, 2015 at 6:44 pm in reply to: Adding a custom body class to several category archives #141948
Gina
MemberI have replied to this twice. Are you getting them? I don't see them on this page so wasn't sure 🙂
February 23, 2015 at 2:12 pm in reply to: Adding a custom body class to several category archives #141907Gina
MemberSo I almost have this resolved 🙂
I added the add action as stated above and it worked EXCEPT it added it to two categories that I did not include and do not want it to be added to: latest-news and upcoming-events.
I'm not sure why it did that. I tried adding an else if but I don't have all of the syntax correct. Can someone please help!!!!
Gina
MemberFor what it's worth, this ended up resolving my issue:
/* add a custom body class */
add_action( ‘body_class’, ‘ilwp_add_my_bodyclass’);
function ilwp_add_my_bodyclass( $classes ) {
if ( is_category( array(parish-plan,residential-emergency-planning,business-emergency-planning,evacuation-guidelines) ) ) { echo ‘hi'; }
$classes[] = ‘hsep';
return $classes;
}February 23, 2015 at 11:52 am in reply to: Adding a custom body class to several category archives #141887Gina
MemberI finally found the answer to this question! I've been trying to figure this out for days 🙂
For multiple categories the below works:/* add a custom body class */
add_action( 'body_class', 'ilwp_add_my_bodyclass');
function ilwp_add_my_bodyclass( $classes ) {
if ( is_category( array(parish-plan,residential-emergency-planning,business-emergency-planning,evacuation-guidelines) ) ) { echo 'hi'; }
$classes[] = 'hsep';
return $classes;
}You can enter the category id instead if you don't have the parent category name inside the body tag.
Gina
MemberDid I provide too much information? LOL Or is there no good answer to this?
Gina
MemberI found this which will enable me to add a custom body class to a category slug but I can only do it with one category and I wasn't able to add it to the parent category homeland-security.
## add a custom body class
add_action( 'body_class', 'ilwp_add_my_bodyclass');
function ilwp_add_my_bodyclass( $classes ) {
if ( is_category( 'custom-category' ))
$classes[] = 'my-custom-class';
return $classes;
}Gina
MemberOh wow do I feel dumb 🙂 THANK YOU SO MUCH! That took care of it.
Gina
MemberWhat I am actually trying to do is style everything with the homeland-security parent category the same way...different nav colors and different sidebar content. There are other ways I can do it but I just thought using the parent category body class would be the easiest way.
Gina
MemberYes I am wanting to add "homeland-security" to the body class. Not sure what you are saying about sub-sub category. Sorry. I read over that codex but I'm just not sure what I'm supposed to do with that info. Oh well. I guess I need to find a different solution. Thank you for trying!
Gina
MemberAm I missing something? This is my example: http://plaqueminesparish.com/wp/category/homeland-security/hsep-in-depth/
hsep-in-depth is the child.
homeland-security is the parent.
Or am I not understanding that correctly?Thank you for your help!!!
Gina
MemberThank you RitzyThemes. I tried add that code but I still don't get the parent category in the body tag for some reason.
Gina
MemberSo nobody has any idea how to do this???
December 19, 2014 at 8:38 am in reply to: Adding Home Middle, Home Bottom Left and Home Bottom Right Widget areas #134899Gina
MemberAwesome! Just what I needed. Thank you very much!
-
AuthorPosts