• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

different color class per page or post?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved

Tagged: body class, remove action, replace color

  • This topic has 3 replies, 2 voices, and was last updated 13 years, 2 months ago by zubird.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • December 21, 2012 at 11:54 am #6693
    zubird
    Member

    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 #6698
    Robert Neu
    Member

    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!

    December 21, 2012 at 12:39 pm #6700
    Robert Neu
    Member

    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!

    December 21, 2012 at 1:01 pm #6705
    zubird
    Member

    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.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble