This question already has an answer here:
I am working on a WordPress theme and I have included Jquery,
// Waves
wp_enqueue_style( 'APKMirror-wave', get_template_directory_uri() . '/inc/waves/waves.min.css');
wp_enqueue_script(
'APKMirror-wave',
get_stylesheet_directory_uri() . '/inc/waves/waves.min.js',
array( 'jquery' )
);
// Boostrap
wp_enqueue_style( 'APKMirror-Bootstrap', get_template_directory_uri() . '/inc/bootstrap/bootstrap.min.css');
wp_enqueue_script(
'APKMirror-Bootstrap',
get_stylesheet_directory_uri() . '/inc/bootstrap/bootstrap.min.js',
array( 'jquery' )
);
The problem is any time I run jQuery code I have to type the word 'jQuery' instead of just using the $. How can I change my code so that it will use $?
jQuery in WordPress runs in noConflict mode which means the global $ shortcut for jQuery isn't available. Use the document ready wrapper which will allow $ to be used as an alias for jQuery.
Or
Thanks to Paulpro for correctly pointing out that there is an alternative that can be used if you need to run the script before the rest of the DOM loads.