different color class per page or post?

Community Forums Forums Design Tips and Tricks different color class per page or post?

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  zubird 1 year, 12 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6693

    zubird
    Participant
    Post count: 5

    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!

    #6698

    Robert Neu
    Participant
    Post count: 90

    Something like this should work:

    http://snippi.com/s/mcqm6zv

    You may need to modify it a bit for the different colors.


    Co-Founder of Audit WP, a WordPress SEO audit service and Flagship, a new WordPress theme company launching soon!

    #6700

    Robert Neu
    Participant
    Post count: 90

    This 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.

    http://snippi.com/s/3ky5lr5

    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.


    Co-Founder of Audit WP, a WordPress SEO audit service and Flagship, a new WordPress theme company launching soon!

    #6705

    zubird
    Participant
    Post count: 5

    Thank 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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.