To include a CSS file and a JS file I added to functions.php
:
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
function my_theme_enqueue_scripts() {
wp_enqueue_script( 'behavior', get_script_directory_uri() . '/behavior.js', array(), null, true );
}
add_action( 'wp_enqueue_style', 'my_theme_enqueue_styles' );
add_action( 'wp_enqueue_script', 'my_theme_enqueue_scripts' );
After doing so, I saved and closed the editor, went back to the same directory of functions.php (this is the child theme's directory), ad created a new file, behavior.js
.
In behavior.js
, I added, just for testing:
alert('Hi');
I saved, went back to my site, and did full refresh, but no alert appears. Why is that?