Customizer API is saving HTML/data changes properly but any CSS change is only visible in the Customizer. After hitting "Save & Publish" the page is exactly like it used to be with no new <style> tags in the <head>. This is the way I declare customizer controls and settings in functions.php (mind you this is not the complete code).

$wp_customize->add_setting('design-header-background-color', array(
    'default' => '#ffffff',
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'design-header-background-color', array(
    'label' => __( 'Background color' ),
    'section' => 'design-header',
    'priority' => 10
function design_header_background_color()
         <style type="text/css">
             header { background-color: <?php echo get_theme_mod('design-header-background-color'); ?>; }
add_action( 'wp_head', 'design_header_background_color');

When I use the control in the Customizer I can see stuff changing properly. But after using "Save & Publish" nothing happens. As I said HTML/PHP manipulations work just fine.

1 Answer 1


OK. Even though I wasn't able to figure it out with CSS and wp_head() I managed to hack something that works.

    $sidebar_background_color = get_theme_mod('design-sidebar-background-color');

<aside style="background-color: <?php $sidebar_background_color; ?>;">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    <?php endif; ?>

Since I could manipulate DOM and HTML just fine I decided to change CSS "manually" as inline styling. It works though the method feels superhacky.

v2 with <style></style> block.

    $header_background_color = get_theme_mod('design-header-background-color');
    $header_background_image = get_theme_mod('design-header-background-image');


    <?php if (get_theme_mod('design-header-css') === '') : ?>
        header .page-header {
            background-color: <?php echo $header_background_color; ?>;
            background-image: url('<?php echo $header_background_image; ?>');
    <?php else : ?>
        <?php echo get_theme_mod('design-header-css'); ?>
    <?php endif; ?>

<!--- HTML GOES HERE -->
  • It works even better when I use <style></style> block. Clears things up.
    – user134865
    Commented Aug 11, 2015 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.