Is it possible to get a theme customizer setting from wp.customize using jquery?

Not sure what you try to accomplish, but you can get a value by key using the wp.customize object:

wp.customize.value('show_on_front')();
wp.customize.value('blogname')();
....

sorry no jQuery here, just javascript, and yes, the extra () are intentional.

Edit: Full overview of all settings:

wp.customize._value;
console.log(wp.customize._value);

Edit II:

different approach:

a) lookup all available settings by using

console.log(wp.customize._value);

b) one can not access the value directly, so

wp.customize._value.blogname

won’t work. But, if you make it a function call it should work:

wp.customize._value.blogname();

I don’t think it’s intended to be used this way ( if there is an intention of usage at all ) but it works for me.
I’ve just inspected the wp.customize object and didn’t look up how WP constructs this _value object.
It’s a good idea to test if a setting is available and if it is a function,and finally you can use jQuery 😉

if ( jQuery.isFunction(wp.customize._value.blogname) ) {
// do stuff
}

or like our parents would have made it 😉

if(typeof wp.customize._value.blogname === 'function')
    //do stuff
{

Leave a Comment