Home › Forums › Themes Support › Claue › How to add javascript file to Child Theme ?
- This topic has 2 replies, 2 voices, and was last updated 5 years, 8 months ago by tutorial.
-
AuthorPosts
-
-
September 2, 2018 at 10:49 pm #24321
Hi,
Now I’m add some custom javascript code into following file. (check the image)
But I need to add that javascript code to child theme because when I add theme update that original theme.js file will be replaced.
So how to add javascript code into Child Theme ?
Best Regards,
Love your theme always !
-
September 3, 2018 at 12:05 am #24327
Hi,
Please create new folder “js” on your child theme and add below code to file functions.php
wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ) );
and change code
function jas_claue_enqueue_script() { wp_enqueue_style( 'jas-claue-parent-style', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'jas_claue_enqueue_script' );
to
*/
function jas_claue_enqueue_script() {
wp_enqueue_style( ‘jas-claue-parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_script( ‘custom-script’, get_stylesheet_directory_uri() . ‘/js/custom_script.js’, array( ‘jquery’ ) );
}
add_action( ‘wp_enqueue_scripts’, ‘jas_claue_enqueue_script’ );with custom_script.js is the file contain your script code.
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
September 3, 2018 at 2:15 am #24330
Thank you!
-
-
AuthorPosts
You must be logged in to reply to this topic.