Jun
07
2010

WordPress 3.0: Activating the Background Editor

by   |  Posted in Tutorials  |  14 comments

Adding a color or image to your Web site’s background is not a very complicated thing to do if you are familiar with CSS. Luckily for those out there who know nothing about CSS, WordPress 3.0 introduces a simple admin user-interface that makes it extremely simple to select a color or image for your background. There are even controls for image position, repeating and attachment.

The new background editor in WordPress 3.0

Activating the background editor only requires that you add one line of code to your theme’s functions.php file.

if(function_exists('add_custom_background')) add_custom_background();

This will add the “Background” link to your Appearance panel in the wp-admin. Placing it inside the function_exists() function makes it backwards compatible in case someone uses your theme with WordPress 2.9.

About the author:

A freelance web developer living in Montreal who spends most of his time writing for this site and building Premium themes for WordPress. You can find him on Twitter @bavotasan.

Site5 Affiliate Link
If you liked this, please share it.

Tags: , , , , , , , , , , , , , ,

Short URL: http://bit.ly/agzW5x

Discussion 14 Comments

  1. Jay on June 24, 2010 at 7:34 pm

    I broke my site trying to probe your tip, :-( I was working with wordpress 2.9 and I decided to update the new 3.0 version. My theme was the magazine basic 2.4. Everything was good till I tryed your tip in the css area. I wrote the piece of code but the error occurred ,I have though in buying the premium version, although I dont know If it is possible to recover somethig of the stuff that was lost. What should I do? I can’t use the admin panel.

    Can I fix it again from the hosting archive.

    I suspect that my partners are going to kill me.

    • c.bavota on June 25, 2010 at 10:03 am

      You are not suppose to add it to the CSS area, you are suppose to add it to the functions.php file.

  2. JAY on June 25, 2010 at 6:02 am

    I am looking in the ftp files of my hosting… Do you know in which file of the css files should I check to fix the error? As far as I remember I changed something in the Sidebar
    if(function_exists ((…)) Can you tell me which file should I correct?

    Thanks in advance

    • JAY on June 25, 2010 at 8:14 am

      The problem is that:

      Parse error: syntax error, unexpected ‘)’ in /homepages/40/d280195945/htdocs/wp-content/themes/Newspaper classic/functions.php on line 895

  3. c.bavota on June 25, 2010 at 10:04 am

    I suggest just installing the latest version of Magazine Basic which has this functionality incorporated into it.

  4. Työnohjaus in Helsinki on April 18, 2011 at 9:59 pm

    Will this work still OK with the newer versions like WordPress 3.1.1?

  5. Gina Jonnson on April 19, 2011 at 8:18 pm

    Thanks for this tip – I have struggled changing backgrounds on some of my Word Press sites. I like the look of your WP themes!

    Gina

  6. Mike K on April 25, 2011 at 5:17 pm

    Not useful to my own sites since I would much easier update the css myself when I want to do that, but this is great for my clients who want this ability and Now I don’t need to program it.

    Thanks,
    Mike

  7. Michael on April 25, 2011 at 8:55 pm

    This is a pretty simple way to change the background image. Thanks.
    Wonder why WordPress doesn’t contain this code OOB?

    • c.bavota on April 26, 2011 at 12:42 pm

      It can’t be OOB since it relies on how theme developers want their themes to function. I think they should all include it but some have custom functions that do that same thing.

  8. Steve Peters on April 26, 2011 at 5:58 pm

    Thanks for taking the time to explain this, it should be quite useful as i am in the process of changing some of my sites over to wordpress.

    Been using xsitepro for a long while but thought it would be good to vary some of them and wordpress seems the easiest option, especially when there are people like yourself willing to share tips and work arounds.

    Steve Peters
    Webmaster inu-dogcare.com
    All about the shiba inu

  9. Catherine on May 12, 2011 at 11:18 pm

    This takes all of the stress out of changing background colors. I welcome any and all tools to make my life a little easier- thanks for the heads up.

  10. Phoenix BMW on May 19, 2011 at 9:16 am

    Thank you C.Bavota!

    You have made it easy to customize backgrounds. I will make sure to remember this and utilize it when I need to change or alter or revamp my own site.

    Along with the info that you have already provided, can you please give a lead on how to alter fonts and if there is a way to introduce fonts that are not available. As in, is there a way to download different fonts and all?

    Brett Michael Williams
    Webmaster, AZBMW