Site logo

Archived topic

Another backgroundcolor on some blog posts?

7 replies · Started by Lars on May 4, 2018

Viewing posts 1–8 of 8

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

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

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
}

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

So each article has a different background color?

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

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.

This archived topic is closed to new replies.