Skip to content

Instantly share code, notes, and snippets.

@sunnymui
Created September 27, 2019 21:13
Show Gist options
  • Save sunnymui/ebac0f16245863858fc581d685fb1794 to your computer and use it in GitHub Desktop.
Save sunnymui/ebac0f16245863858fc581d685fb1794 to your computer and use it in GitHub Desktop.
[Wordpress] Enqueue a child theme's custom.js file to replace the parent's custom js file for better theme modularity
function child_enqueue_scripts() {
// enqueue's js files in the child theme directory so it can replace parent js files
// dequeue the parent's custom js file
// put the name of the parent theme's script used to enqueue it that you want to dequeue
wp_dequeue_script('givingpress-lite-custom');
// enqueue the child theme directory's custom js file
// enqueue the custom.js file in the child theme directory
wp_enqueue_script( 'givingpress-lite-custom', get_stylesheet_directory_uri() . '/js/jquery.custom.js', array( 'jquery', 'superfish', 'fitvids', 'masonry' ), '20190822', true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment