Sunday, June 10, 2018
WordPress 3 0 Theme Tip Custom Backgrounds
WordPress 3 0 Theme Tip Custom Backgrounds
April 12, 2010, 9:35 am
The Custom Background screen is easy to add to any theme
1 | add_custom_background(); |
Details
Okay, so your theme does need to have the normal wp_head() call in it. For those of you more CSS inclined, this basically creates CSS code for the body and adds that code to the head output directly. Voila, your theme gets styled.Note that you will need to also not define your own background stuff in the theme for this to work. If the user tries to put in a solid color background and you define an image background, then the color won�t work or be visible over your image. Best to not put anything background related onto the body at all, in fact.
Customization
For those more inclined to customize things, there�s actually three parameters you can use:1 | function add_custom_background($header_callback = , $admin_header_callback = , $admin_image_div_callback = ) |
The header_callback function is what builds and outputs the CSS. The function takes no parameters, but it can use get_background_image() and get_background_color() to retrieve the necessary information. From this information, the function should produce and output (echo) the necessary