Menu Close

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.


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

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">

View Source
Posted in WordPress