The Goal:
Use the functions.php file to properly add custom scripts to your child theme.

This is the preferred method to adding custom scripts and styles to a website’s child theme.

Requirements:

  • Access to functions.php

functions.php

Add this to code to the bottom of your functions.php file.

[cc lang=”html”]
// CUSTOM SCRIPTS
function my_assets() {
wp_enqueue_script( ‘custom-scripts’, get_stylesheet_directory_uri() . ‘/custom.js’, array( ‘jquery’ ) );
}

add_action( ‘wp_enqueue_scripts’, ‘my_assets’ );

[/cc]

Share This