Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Support request] Another backgroundcolor on some blog posts?

Home Forums Support [Support request] Another backgroundcolor on some blog posts?

Home Forums Support Another backgroundcolor on some blog posts?

  • This topic has 7 replies, 2 voices, and was last updated 3 years ago by David.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #567961
    Lars

    Hi, I wonder if there is any option to set so I can get another background color on a blog post. For example, the default color is white, but some posts can be set in another background color. / Lars

    #568032
    David
    Staff
    Customer Support

    Hi Lars,

    The simplest option would be to use the Simple CSS plugin. Then you can add page specific CSS via the meta box provided in the page editor and use this code:

    body {
        background-color: #AABBCC;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    #569471
    Lars

    Hi David!

    Thank you very much for the reply. I realized that I did not put my question correctly. What I’m looking for is the background color of the content area. The background color of the post should therefore be unique to just one post. Hope you understand what I mean. / Lars

    #569484
    David
    Staff
    Customer Support

    Hi Lars

    are you using a single container or separate container layout?

    For single container this:

    .container {
    	background-color: #AABBCC !Important;
    }

    For separate containers you can do this:

    .inside-article, .comments-area {
    	background-color: #AABBCC !important
    }
    #569487
    Lars

    Hi!
    I use separate container layout, thanks now I got it.

    One last question for now, is it possible that the background color is also visible in the blog flow? / Lars

    #569494
    David
    Staff
    Customer Support

    So each article has a different background color?

    #569603
    Lars

    Letś say that I have 5 posts on my blog flow, all have the default background color in the container, all except post 2 that has a red background container. /Lars

    #569639
    David
    Staff
    Customer Support

    Thats a fun one. Not easy, but how about we use Taxonomies to style the different backgrounds?
    By default WP adds the taxnomies as classes to the article e.g category-red or tag-blue so you can use them to style elements like so:

    .tag-red .inside-article, 
    .tag-red ~ .comments-area {
    	background-color: red;
    }

    Now any article with a Tag of Red will get those styles. Just create a library of tag colours as you go =) And you can scrap the above CSS as this will apply to blog and single posts.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.