How do I use WP’s jQuery

WP’s jQuery is not mapped to $ like you may expect, it is loaded in noConflict mode so you’ll need to use jQuery() instead of $(), unless you map it yourself.

When you include your js file you’ll want to make sure to set jQuery as a dependency as well:

wp_enqueue_script( 'your-script-handle', get_stylesheet_directory_uri() . '/js/your-script.js', array( 'jquery' ), '1.0.0' );

Leave a Comment