• Hi

    I’m trying to get my 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');

    What am I doing wrong here?

Viewing 1 replies (of 1 total)
  • Thread Starter madsrh123

    (@madsrh123)

    I’ve also tried this – again without luck

    // Custom background Color
    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' );
Viewing 1 replies (of 1 total)
  • The topic ‘Set background color on theme load’ is closed to new replies.