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!
P粉9147310662024-03-29 13:48:08
If you change/add the following php code to the body
tag in the header.php
file...
<body <?php body_class(); ?> >
..., 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 with background-color
for that id (#page-id-xxx { background-color: #abc; }
and add it to Generic stylesheet or just access the page through the customizer.
P粉1781328282024-03-29 09:16:19
Finally, I decided to apply full transparency to all levels of container elements within the body:
background-color:rgba(0,0,0,0.0) !important;
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! ! !