Home Forums Themes Support Claue How to add javascript file to Child Theme ?

Topic Resolution: Resolved
Viewing 2 reply threads
  • Author
    Posts
    • #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 !

    • #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

    • #24330

      Thank you!

Viewing 2 reply threads

You must be logged in to reply to this topic.