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">
Thank you for this short but great post. I have been struggling with this background problem. Helped a lot.
Your alternative fix, though marked as not recommended, saved my day. Thanks.
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.
Thank you, it’ realy good solve! I’am use and with my template it works! Great.
Thank you SO much! been trying to figure this out for an hour. So helpful.
Thanks, it helped me a lot! 🙂