Skip to content

Instantly share code, notes, and snippets.

@Edwardtonnn
Last active September 11, 2023 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Edwardtonnn/a2efca260cda3f6caaa79a23122cfe4d to your computer and use it in GitHub Desktop.
Save Edwardtonnn/a2efca260cda3f6caaa79a23122cfe4d to your computer and use it in GitHub Desktop.
wp_enqueue script
(function($) {
// $ Works! You can test it with next line if you like
console.log("I'm alive!");
})( jQuery );
//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