Best wordpress security & maintenance

To be able to add jQuery to the WordPress you first need to create js folder in your theme / child-theme directory.

After that create example.js file in the js directory.

Then in the functions.php add next code:

/*add jquery to the WP*/
add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
    wp_register_script(
       'child-theme-script', 
       get_stylesheet_directory_uri() . '/js/example.js', 
       array('jquery') 
    );

    wp_enqueue_script('child-theme-script');
}

example.js change with the actual name of the file that you have created in the child-theme/js folder

Pin It on Pinterest

Share This