20 Responses

  1. Phil
    Phil June 8, 2011 at 2:34 pm |

    Exactly what I needed! Thanks!

    Reply
  2. Jimo
    Jimo June 8, 2011 at 3:04 pm |

    Really useful tip!
    Unfortunately I realized it too late. In my themes I used to create my own custom function and everything worked great, but the last time I said “hei, why add unnecessary code when there is already the default function of WordPress, which does exactly the same thing??” How wrong I was …
    Unfortunately neither I nor the reviewer have noticed this problem in the theme before it was released.
    However, as well as I do not agree the logic with which the function of WP handles the background – as you said, there’s pros and cons – , I think it lacks of the “position-y” option, which could be useful for fixed backgrounds.

    Reply
  3. Thomas
    Thomas June 9, 2011 at 9:17 am |

    Hi Justin,

    thanks for this useful tip. I haven’t noticed this “bug” until today ;)

    All of my published themes use the custom background function and have luckily no default background image, only color.
    But I have a new theme ready to publish with default background image. Good to know I can fix this bug now before it goes online.

    Cheers,
    Thomas

    Reply
  4. Rilwis
    Rilwis June 9, 2011 at 10:14 am |

    A nice tutorial. Actually, I don’t often use custom background in my themes as I always fixed the background by CSS, but this’s really needed when users need to change the background themselves. Thanks.

    Rilwis.

    Reply
  5. Lillan Backa
    Lillan Backa June 15, 2011 at 12:14 pm |

    Nice tut! I have had my thoughts about it, especially when it comes to make use of an option panels AND the ability to “add_custom_background”. This fix opens more flexibility, and besides that – i learned something new today :)

    Tnx, Lillan

    Reply
  6. Jeff
    Jeff June 19, 2011 at 1:24 pm |

    Justin, you are a genius! I didn’t even know I needed to fix this. Thanks!

    Reply
  7. WordPress Community Links: Mobile townhall edition | WPCandy
  8. Wordpress Anpassen » Wordpress Custom Background Funktion Bugfix
  9. A_Flama
    A_Flama October 7, 2011 at 9:35 pm |

    Nice Tip!!! Thanks :)

    Reply
  10. pikolo
    pikolo January 15, 2012 at 5:06 pm |

    hi , my wordpress don’t display image background

    file function.php

    body {  }

    style.css

    body { background: #b7b7b7 ; }

    color is ok, but something wrong is with image , great thanks and regard

    Reply
  11. Alex
    Alex June 25, 2012 at 8:37 am |

    WordPress 3.4 is here, and it seems that the problem still exists. How would I go about solving it, now that the function add_custom_background is deprecated?

    Reply
  12. Daniel
    Daniel December 13, 2012 at 6:16 am |

    @pikolo and Alex

    I added this in my functions.php:

    // Add support for custom backgrounds.
    	add_theme_support( 'custom-background', array(
    		// Let WordPress know what our default background color is.
    		// This is dependent on our current color scheme.
    		'default-color' => $default_background_color,
    	) );

    and this in my start body tag in my header.php:

    It did the trick also in WP 3.5

    hope it helps

    Reply
  13. Selic
    Selic March 6, 2013 at 2:01 am |

    Thanks

    Reply
  14. vigneshraj.n
    vigneshraj.n April 5, 2013 at 2:30 am |

    hey i added both add_custom_background() and its new replacement but nothing seems to work, i tried your example too..i feel so stupid right now.. please help.. shoild i add something in header.php or index.php..?

    Reply

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.