Create a /js
subfolder in your theme directory, if such does not exist already.
Save your script to a file in said folder.
Then, in functions.php:
if ( is_admin() ) {
global $pagenow;
if ( 'customize.php' === $pagenow ) {
add_action( 'admin_enqueue_scripts', 'wpse107236_enqueue_customizer_script' );
}
}
function wpse107236_enqueue_customizer_script() {
wp_enqueue_script(
'your-script-handle',
get_template_directory_uri . '/js/your-script.js',
array( 'jquery' ),
'1.0',
true
);
}
Related Resources:
Related Posts:
- Remove type attribute from script and style tags added by WordPress
- How to remove Customize from admin menu bar after WP 4.3
- AJAX handler throws 400 (Bad request) – why?
- ajax live search for post title
- How to save Uploaded image in custom option panel?
- Add inline css to theme
- Restrict user registration to emails on a single domain
- Widgets Section not displaying in theme customizer
- jQuery plugin function is not a function
- Display a function using AJAX
- Enqueuing Script in functions.php vs on the page
- Using the child theme functions.php to change the customizer.php on parent theme
- Add external js file to footer with id
- Ajaxing function in widget class
- woocommerce target button with class after ajax update
- Move jQuery and Migrate to footer?
- jquery won’t load in footer
- WordPress doesn’t Load JQuery Now? Do I need to enqueue JQuery also?
- Customizer field value into functions.php variable
- Woocommerce checkout field maxlength, make input number field only (postcode)
- PHP files included in functions.php don’t seem to work
- Replace menu links with # and add name to its li
- Loading CDN that requires jQuery in WordPress
- How to load jQuery in the footer – nothing works for me
- Not sure if enqueuing js scripts properly
- Wp_query function to search from product_title ‘OR’ product tags name
- Allow Post Author to be 0 on Update
- Trouble with adding a wp_enqueue_script on wordpress
- WP Ajax Function Always Returning undefined
- Scripts not appending to element in AJAX call – why?
- How to change the order of Jquery in the footer of my theme?
- How to search using ajax for exact phrase or words in an input field?
- how to en-queue jQuery to load before the tag
- I can’t enqueue my scripts – They literally aren’t being added to my site
- Attempt to change jQuery version caused White Screen of Death
- Load jquery only for certain pages in the backend
- Change CSS for logged in users
- Always the Latest google jQuery instead of default WordPress jQuery
- Add a jQuery Function
- jQuery does not work
- Can’t call Javascript function – scope?
- Changing parent element’s class or style
- Enqueuing latest version of jQuery into a child theme returns a blank screen
- echo custom fields with AJAX
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- laoding bloginfo url in function array?
- In jquery use php variable to execute an enqueued jquery file
- Run a jquery script on on a certain template page
- Add php code to wp_print_scripts?
- How can i unload effect.min.js file?
- Where do I go to edit this area? [closed]
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- Where is this JQuery coming from?
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- Combine two active_callbacks into one on theme customizer
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- WP Customizer API loaded into functions.php
- How to load jQuery in TOP of wp_footer?
- Different methods of adding menu support to custom theme
- WordPress can’t get jquery/unslider to work
- Add loggedout class on body using a function or JS
- Are innerHTML elements visible to jQuery functions?
- Include Jquery libraries in wordpress theme?
- contact form in template with jquery,validate and ajax
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- get content from page through AJAX
- Creating multiple category drop down
- Theme Customizer – Custom Sections Display, but do Nothing
- How to setup a popup registeration page in wordpress with function.php
- colorbox not loading in
- How to add php within jquery
- Help with IF has focus then… statment
- Astra theme – cannot set short product description under the product title (product name)
- wp_set_object_term via js btn frontend
- Populate Product Regular Price with a calculated ACF Field Value
- Hide ‘add to cart’ when certain value in dropdown is selected
- post value to function with Ajax and jQuery
- Images with overlay
- How to use `foreach()` in ajax call
- Change default color scheme in twentyfifteen child theme?
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- WordPress Ajaxifying not working properly
- How to create a WordPress Customizer Button to Clear a Cache?
- Execute jQuery with custom event listener after successfully add an item to the cart
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- Automatic add space if user enters number(any digit)
- WordPress Jquery+scripts enqueue issue
- Moving CDN jQuery to footer does not work?
- Adding a jQuery rotator function
- Can’t wrap my head around this function – any help would be appreciated
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- How to use different jquery function of idangero swiper dependant on page template?
- Ajax call does not work for this custom code
- How do I get my nav menu to show sub pages?
- Having problems loading Jquery in functions.php
- Owl Carousel and WordPress Integration Via WP_Enqueue
- Custom customizer CSS priority
- Customizer cuistom CSS Priority ordre Issue