Skip to main content
Easily create better & faster websites with the Total WordPress Theme Learn More
(opens a new tab)
Tutorials

Custom Background Not Working In WordPress

Custom Background Not Working In WordPress

I’ve gotten a couple questions already from people having issues with their custom background options in WordPress after upgrading to WordPress 3.3. In the past I didn’t use the <body_class() ?> function much in my themes as I never really made use of any of the classes added dynamically to the body tag. However, with WorPress 3.3 it is key since now the custom background function makes use of it.

In WordPress 3.3 when you add your custom background instead of applying the styling to your “body” tag as it did before it now adds a new class called “custom-background” and applies the css to that instead.

Example:

<style type="text/css"><br />
body.custom-background { background-color: #921d1d; }<br />
</style><br />

Since it applies the styling to that specific class you will need the custom-background class in your body tag.

The Fix

Open header.php and locate your <body> tag. Change to:

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

Alternative “Fix”

Of course if you don’t want to have the extra classes you can always change the body tag to this (not recommended):

<body class="custom-background">
6 Comments
  1. Ozhan · 12 years ago

    Thank you for this short but great post. I have been struggling with this background problem. Helped a lot.

  2. Catzie · 12 years ago

    Your alternative fix, though marked as not recommended, saved my day. Thanks.

  3. MarcC · 12 years ago

    Thank you so much for this fix, scratched my head (and google’s) for long enough trying to fix the custom background image issue.

    Again, thank you.

  4. wordman · 11 years ago

    Thank you, it’ realy good solve! I’am use and with my template it works! Great.

  5. sienagabrielle · 10 years ago

    Thank you SO much! been trying to figure this out for an hour. So helpful.

  6. malipi (@malipi) · 10 years ago

    Thanks, it helped me a lot! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Learn how your comment data is processed by viewing our privacy policy here.