I’m building a custom WordPress theme for a client and using a child theme.
I want to enqueue my custom CSS (style.css
) and a JavaScript file (custom.js
) located in the child theme’s folder.
Here’s what I’ve tried in functions.php
:
function my_custom_scripts() {
wp_enqueue_style('my-style', get_stylesheet_directory_uri() . '/style.css');
wp_enqueue_script('my-script', get_stylesheet_directory_uri() . '/custom.js');
}
add_action('wp_enqueue_scripts', 'my_custom_scripts');