在主题加载上设置WP custombackground颜色

I'm trying to get my Wordpress twentytwelve child theme to make sure that when the theme is activated the background is white. I can't just add the CSS to the wp_head because then the user can't set a custom background.

I've been looking at the after_setup_theme hook

 function set_white_bg() {
 set_theme_mod( custom-background, 'ffffff');   }
 add_action('after_setup_theme', 'set_white_bg');

I've also tried this - again without luck

function wpse64373_set_custom_background( $new_colour )
{
$old_colour = get_theme_mod(
     'background_color'
    ,get_theme_support( 'custom-background', 'default-color' )
);

  if ( $old_colour == $new_colour )
    return;

return set_theme_mod( 'background_color', $new_colour );
}

function wpse64373_update_custom_background()
{ wpse64373_set_custom_background( 'ffffff' ); }
 add_action( 'switch_theme', 'wpse64373_update_custom_background' );

What am I doing wrong here?

Try to add this in your child theme's function.php

add_action('after_setup_theme','child_default_background_color');
function child_default_background_color() {
    $theme_options = get_option( 'twentytwelve_theme_options');
    if ( 'dark' == $theme_options['color_scheme'] )
        $default_background_color = 'ffffff';
    else
        $default_background_color = '333333';

    add_theme_support( 'custom-background', array(
        // set default background color in child theme
        'default-color' => $default_background_color
    ) );
}