Last active
September 11, 2023 21:24
-
-
Save Edwardtonnn/a2efca260cda3f6caaa79a23122cfe4d to your computer and use it in GitHub Desktop.
wp_enqueue script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
// $ Works! You can test it with next line if you like | |
console.log("I'm alive!"); | |
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Just the script | |
wp_enqueue_script( | |
'custom', | |
get_stylesheet_directory_uri() . '/js/custom.js', | |
array('jquery'), | |
null, | |
true | |
); | |
//The entire function | |
//Function includes deregistering the default jquery | |
// include custom jQuery | |
function shapeSpace_include_custom_jquery() { | |
wp_deregister_script('jquery'); | |
wp_enqueue_script( | |
'jquery', | |
'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', | |
array(), | |
null, | |
true); | |
} | |
add_action('wp_enqueue_scripts', 'shapeSpace_include_custom_jquery'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment