Default Custom Background for WordPress 3.4

Custom backgrounds are handled through add_theme_support since WordPress 3.4, and although you can add your custom callback to wp_head, you don’t need you. You can simply pass a default-image to add_theme_support for your custom background:

add_theme_support( 'custom-background', array(
	'default-image' => get_template_directory_uri() . '/images/default-background.png',
) );

The default custom background image will be used when one is not set, or the user hits the “Restore Original Image” button in the custom background options. However, the old method should still be compatible with WordPress 3.4, unless you’re doing something wrong :)

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.