![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/ab6dc08a67065e0025b27dbcd480e95d-87a1c39.jpg)
Hi guys,
I need to change the background color of my site, only blog page (home.php).
I have changed this class .tm-main in the style.css of my my child theme.
1) I have inserted this code for all page:
.tm-main {
background-color: #fff;
}
2) Now i want apply this another rule only for home.php.
.tm-main {
background-color: #f5f5f5;
}
How can I do?
Fabio
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/943316fb9ad362791bb13454556f8776-87a1c39.jpg)
You can use Conditional Tag is_home(). Ex:
// Setup homepage bg color
beans_add_smart_action( 'wp', 'fabio_setup_bgcolor' );
function fabio_setup_bgcolor() {
if (is_home())
beans_add_attribute( 'beans_main', 'class', 'bg-color' );
}
Then add CSS for
.bg-color
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/ab6dc08a67065e0025b27dbcd480e95d-87a1c39.jpg)
Thank you Trung Nguyen. I've solved.
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/943316fb9ad362791bb13454556f8776-87a1c39.jpg)
Which way Fabio?
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/ab6dc08a67065e0025b27dbcd480e95d-87a1c39.jpg)
I used your solution:
I've change my idea, and i decided to apply on all wordpress pages one type background, while apply another background on all post /articles.
So I solved with your solution , like this...
In my function.php this:
// Setup all pages bg color
beans_add_smart_action( 'wp', 'fabio_setup_bgcolor' );
function fabio_setup_bgcolor() {
if (is_page())
beans_add_attribute( 'beans_main', 'class', 'bg-color' );
}
In my style.css this:
/* main background color for every posts */
.tm-main { background-color: #f5f5f5; }
/*background color for all pages*/
.bg-color { background-color: #fff; }
Thank you
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/943316fb9ad362791bb13454556f8776-87a1c39.jpg)
God job!
By the way, amazing website, buddy (Fabiographic) π
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/ab6dc08a67065e0025b27dbcd480e95d-87a1c39.jpg)
Ahahahah, Thanks so much, friend! π
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hey guys,
The solution to add a class on home is good and shows your great understanding of how Beans work π For that specific case though, note that WordPress automaticall adds a home
class to the body
markup on the home page. So without add a class via PHP, you could simply add the following CSS:
/* Main background color for every posts. */
.tm-main {
background-color: #f5f5f5;
}
/* Background color for the home page */
.home .tm-main {
background-color: #fff;
}
Happy coding,
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/943316fb9ad362791bb13454556f8776-87a1c39.jpg)
Wow, too fast.
@Thierry: How do I have deep understanding about WordPress like you? (really need a advice, I worked hard with WordPress but there are many things that i don't know about WP)
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hi Trung, the best advise I can give is to continue building cool things. It is the best way to learn! It doesn't come overnight though, I have been writing code for WordPress for close to a decade and I am still discovering new stuff everyday π
Keep up the good work,
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/943316fb9ad362791bb13454556f8776-87a1c39.jpg)
Thanks very much brother. I want to discovering Beans source code. but i don't know where to start.
Any suggestion for me, Thierry?
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hey Trung,
Beans Core may seem a bit complex but it is actually well organized and follow the same logic throughout the framework. I would start by reading this article to understand the basic and then start by looking in the lib/init.php
which is where everything starts π
Have fun,