Child Theme Path Being Ignored With wp_enqueue_scripts

get_template_directory_uri() is explicitly for getting the URL to the parent theme, which is why your scripts and styles are being enqueued at that path (in this context the “template” is the parent theme).

The equivalent function for getting the child theme path is get_stylesheet_directory_uri(). If you don’t have a child theme then both these functions do the same thing, but when you are using a child theme the choice is important.

However, both these functions have been superseded by much more useful functions: get_theme_file_uri() and get_parent_theme_file_uri().

get_theme_file_uri() will get the URL to a specific file in your theme. If your theme is a child theme it will look for the file there, but if it can’t find it, it will look in the parent theme. get_stylesheet_directory_uri() can’t do this.

So for your use case, you should use get_theme_file_uri():

wp_enqueue_style('bootstrap', get_theme_file_uri( 'assets/css/bootstrap.min.css' ), [] );
wp_enqueue_script('bootstrap', get_theme_file_uri( 'assets/js/bootstrap.min.js' ), [] );

The main difference in usage is that rather than concatenating the rest of the file path to the end, you pass it as an argument. This is why it’s able to check the parent theme for the file.

tech