20 Responses

  1. Phil
    Phil Published |

    Exactly what I needed! Thanks!

  2. Jimo
    Jimo Published |

    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.

  3. Thomas
    Thomas Published |

    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.


  4. Rilwis
    Rilwis Published |

    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.


  5. Lillan Backa
    Lillan Backa Published |

    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

  6. Jeff
    Jeff Published |

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

  7. WordPress Community Links: Mobile townhall edition | WPCandy
  8. Wordpress Anpassen » Wordpress Custom Background Funktion Bugfix
  9. A_Flama
    A_Flama Published |

    Nice Tip!!! Thanks 🙂

  10. pikolo
    pikolo Published |

    hi , my wordpress don’t display image background

    file function.php

    body {  }


    body { background: #b7b7b7 ; }

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

  11. Alex
    Alex Published |

    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?

  12. Daniel
    Daniel Published |

    @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

  13. Selic
    Selic Published |


  14. vigneshraj.n
    vigneshraj.n Published |

    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..?

Comments are closed.