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;
    /* background-image:url('../images/backgrounds/bg4.png'); */

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?

  • I can add that just using add_theme_support( 'custom-background');instead and then upload a file from the admin is what I want, but that ends up in the same way, i have just recently changed it to this code I posted first since I wanted to see if it made any difference
    – emcolsson
    Mar 8, 2017 at 12:52
  • Since you already shared your domain, could you possibly provide a link where I can see the issue? Your current homepage does not have a bg image set from what I can see?
    – Svartbaard
    Mar 8, 2017 at 13:28
  • @Svartbaard Oops.. well, I deactivated my coming soon landing page for now so you can have a look. Now I have commented out the line in the css and in the wp-admin I have set the background-image.
    – emcolsson
    Mar 8, 2017 at 15:00

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 ... " >
  • That did indeed work! Thank you so much, I can now change in wp-admin and it makes the changes. Since im new to this I will soon encounter similar issues. Do you have any input or know wheres there documentation on what I do have to call to make everything work - like this one? Like for example if i would like to the same with custom header.
    – emcolsson
    Mar 8, 2017 at 15:03
  • Glad to hear it worked. The best source is the code itself, The Code Reference is helpful. It's also informative to look into the default themes to see how they are implementing things..Best of luck @emcolsson
    – birgire
    Mar 8, 2017 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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