Answer the question
In order to leave comments, you need to log in
Changing the color of some divs to the same as body.custom-background?
I change the background color in the theme using wp-admin/customize.php in the WP console
. After that, the body has an additional class body.custom-background.
How can I now apply this color to some more divs in this theme?
I tried to add this class via
const element = document.querySelector('.site-title');
element.classList.add('custom-background');
Answer the question
In order to leave comments, you need to log in
Question - how?
... apply this color to some more divs in this theme?
add_action('wp_head','div_style');
if(!function_exists('div_style')){function div_style(){?>
<style id="div_style" type="text/css">
.div_style{background-color:#<?php echo get_theme_mod('background_color');?>;}
</style>
<?php }}
...............или...............
add_action('get_footer','div_style');
if(!function_exists('div_style')){function div_style(){?>
<style id="div_style" type="text/css">
.div_style{background-color:#<?php echo get_theme_mod('background_color');?>;}
</style>
<?php }}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question