Created
September 27, 2019 21:13
-
-
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
This file contains hidden or 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 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