Knowledgebase: WordPress > Glossary
What are Custom Backgrounds
Posted by Benjamin Antenor, Last modified by Aaron Eaton on 08 March 2016 10:28 AM

Custom Backgrounds is a theme feature in WordPress which allows theme developers to enable support for background color and image customizations. If custom backgrounds support is enabled in a theme, then the users can upload their own background images to use with the theme, or select a background color. The option to change background colors or change the background image is found under Appearance in the sidebar of WordPress Admin Panel.

The link to change or modify settings is titled Background and gives the option to upload a custom background image or select a background color. There is also a preview panel right above the upload section to show a preview of what the custom background color or image will look like. On many themes this feature will not be enabled (such as for custom themes made for one specific website rather than templates which will be across multiple websites). The feature can be added to themes and enabled by modifying the functions.php file. The process for doing this is shown below.

How to Add Custom Backgrounds Support to a WordPress Theme

To enable custom background support add the add_theme_support() function in your theme’s functions.php file with the following configuration.

Example:

$defaults = array(
	'default-color'          = '#EEEEEE',
	'default-image'          = get_template_directory_uri() . '/images/default_background.jpg',
	'wp-head-callback'       = '_custom_background_cb',
	'admin-head-callback'    = '',
	'admin-preview-callback' = ''
);
add_theme_support( 'custom-background', $defaults );

Ensure you change the default-image option within the defaults array to match the location of an image you have in your theme.