0

I use the Theme Customizer pretty extensively and I want to add some Javascript code into the Customizer .

How do I go about doing this? Can't figure it out for the life of me...

Thanks!

  • you mean the customizer itself? – David Lee Feb 18 '17 at 1:53
2

You use the customize_controls_enqueue_scripts action hook for that. Then you enqueue script as usual. Like this:

function wpse256911_customizer_enqueue() {
    wp_enqueue_script( 'my-customizer', get_stylesheet_directory_uri() . '/js/my-customizer.js', array( 'jquery', 'customize-controls' ) );
}
add_action( 'customize_controls_enqueue_scripts', 'wpse256911_customizer_enqueue' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.