Custom Background-Image not showing up

I have added theme_support for my background-image and its showing up in the admin where I can set it and from there it looks as it should, but if i go to my website outside of the admin the background is completely white.

I can un-comment this section in my css to make it work

    body {
    font-family: Georgia, "Times New Roman", Times, serif;
    height:100%;
    /* background-image:url('../images/backgrounds/bg4.png'); */
    margin:0;   
}

but the whole idea is to be able to set it from the admin panel so the template can be used easily by others.

my support code looks like this:

    $args = array(
    'default-color' => '000000',
    'default-image' => get_template_directory_uri() . '/images/backgrounds/bg4.png',

);
add_theme_support( 'custom-background', $args );

also, if i inspect my site i can see the line:

body.custom-background { background-image: url("http://www.emcolsson.se/wp-content/themes/emcolsson/images/backgrounds/bg4.png"); background-position: left top; background-size: auto; background-repeat: repeat; background-attachment: scroll; }

which to me is saying that it works since I think its that line of code that is generated when an custom background is chosen from the admin panel, but at the same time it doesnt?

1 Answer
1

It could be that you’re missing the the body_class() in your theme:

<body <?php body_class(); ?>>

It should add the .custom-background as a body class:

<body class=" ... custom-background ... " >

Leave a Comment