I have a specific page and I just need to change the background color of that page, the page structure starts like this:
<body class="..."> <div class="start-class"> ...... </div> </body>
I want to put functions.php
, for example:
add_filter( 'body_class', 'my_css'); function my_css( $classes ) { if ( is_page(82) ) find div that has specific "start-class" because it doesn't have any id $classes[] = 'my-custom'; return $classes; }
Is there any way to add it? ..thank you all! ! cheers!
If you change/add the following php code to the
body
tag in theheader.php
file......, WordPress will automatically add the "body class", which has a
page-id-xxx
, where "xxx" represents a separate id number for each page, corresponding to the page id in the database. You can then create a CSS rule withbackground-color
for that id (#page-id-xxx { background-color: #abc; }
and add it to Generic stylesheet or just access the page through the customizer.Finally, I decided to apply full transparency to all levels of container elements within the body:
I can use
add_filter( 'body_class', 'my_css'); in the body whenever applicable
I said in the post that this would make my life easier... Thanks anyway @Johannes, @Broe, @Rahul Srivastava! cheers! ! !