How to add jQuery script into WordPress

How to add jQuery script into WordPress

You can add jQuery scripts to your WordPress site by utilizing some built-in WordPress functions which direct the CMS to load the script after jQuery has been loaded so that the jQuery alias $ is not undefined.

1.) Upload your script to: wp-content/themes/[theme-name]/assets/js/
2.) Open: functions.php
3.) Register script using wp_register_script() function
4.) Add action using add_action() function

 * Theme functions and definitions.
if ( ! defined( 'ABSPATH' ) ) {

function nthEverything() { 
		get_template_directory_uri() . '/assets/js/jquery.nthEverything.js', 
add_action('wp_enqueue_scripts', 'nthEverything');

Additional Links

Leave a Reply

Your email address will not be published.