Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Class Reference/WP Customize Manager/get setting


$wp_customize->get_setting() can be used to modify properties of a setting that has already been created (for instance, one of WordPress's built-in settings).

This method is generally only used within the customize_register action hook.


This method returns an object matching any arguments provided in the $wp_customize->add_setting() method (default, type, capability, or transport)


For example, if you needed to change the transport method of one of WordPress's built in theme settings, you might use one of the following...

$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->get_setting( 'background_color' )->transport = 'postMessage';

if you needed to change a default (such as a default color), you might use...

$wp_customize->get_setting( 'header_textcolor' )->default = '#ffffff';
$wp_customize->get_setting( 'background_color' )->default = '#000000';


See also index of Class Reference and index of Function Reference.