Community Forums › Forums › Design Tips and Tricks › different color class per page or post?
Tagged: body class, remove action, replace color
This topic contains 3 replies, has 2 voices, and was last updated by zubird 5 months ago.
-
AuthorPosts
-
December 21, 2012 at 11:54 am #6693
I am using the Streamline theme and would like to leave my chosen green color class in place for the home page (and a few other pages). However, I would like to have the color class change based upon certain pages or posts. I am able to add a different color class (through functions or on page body classes field) but so far have not been successful at removing the original color. Is there a way to remove or replace the green color? Here is what I was trying:
/** Remove custom body class for certain pages or categories */
remove_action( ‘body_class’, ‘remove_green_class’ );
function remove_green_class( $classes ) {
if ( in_category( ’4′ ) OR ( is_page( 164 || 351 || 240 || 191 || 243 || 68 )))
$classes[] = ‘streamline-green’;
return $classes;
}/** Add custom body class to the head for certain pages or categories */
add_action( ‘body_class’, ‘add_orange_class’ );
function add_orange_class( $classes ) {
if ( in_category( ’4′ ) OR ( is_page( 164 || 351 || 240 || 191 || 243 || 68 )))
$classes[] = ‘streamline-blue’;
return $classes;
}I’ve also tried creating a page template that includes the alternate color body class to no avail. The original color just sticks.
Thank you!
December 21, 2012 at 12:17 pm #6698Something like this should work:
You may need to modify it a bit for the different colors.
December 21, 2012 at 12:39 pm #6700This will let you control which class is applied when someone is on a page other than the ones you’re trying to modify. I also noticed the way you were passing the pages in is_page() was incorrect so that was causing an issue as well.
Just make sure that in your Genesis theme options you’ve set the color setting to default or remove the support for the genesis-style-selector entirely.
December 21, 2012 at 1:01 pm #6705Thank you! I think I can make this work. As a former Thesis user I must admit, there are so many more examples out there for Thesis. I’ve been looking for examples for hours and appreciate your help.
-
AuthorPosts
You must be logged in to reply to this topic.