Warning: This function has been deprecated. Use add_theme_support() instead.

add_custom_background() WordPress Function

The add_custom_background() function allows you to add a custom background to your WordPress site. This function takes two arguments: a callback function that defines the background image and a default color. The callback function is used to define the background image. It takes two arguments: the first argument is the name of the image file, and the second argument is an array of optional image properties. The default color is optional and can be any valid hex color code. This function can be used in conjunction with the remove_custom_background() function to remove a custom background from your WordPress site.

add_custom_background( callable $wp_head_callback = '', callable $admin_head_callback = '', callable $admin_preview_callback = '' ) #

Add callbacks for background image display.


Description

Top ↑

See also


Top ↑

Parameters

$wp_head_callback

(callable)(Optional)Call on the 'wp_head' action.

Default value: ''

$admin_head_callback

(callable)(Optional)Call on custom background administration screen.

Default value: ''

$admin_preview_callback

(callable)(Optional)Output a custom background image div on the custom background administration screen. Optional.

Default value: ''


Top ↑

Source

File: wp-includes/deprecated.php

function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) {
	_deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' );
	$args = array();
	if ( $wp_head_callback )
		$args['wp-head-callback'] = $wp_head_callback;
	if ( $admin_head_callback )
		$args['admin-head-callback'] = $admin_head_callback;
	if ( $admin_preview_callback )
		$args['admin-preview-callback'] = $admin_preview_callback;
	return add_theme_support( 'custom-background', $args );
}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Use add_theme_support()
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More