Loading my main.js file from my child theme

On line 18 of your child theme’s functions.php you are enqueuing main.js with get_template_directory_uri(). That function is returning the path to you’re parent theme. Try replacing it with get_stylesheet_directory_uri(), which will return the path to your child theme’s root directory.

I can’t blame you for not realizing the difference though. The developer.wordpress.org entry for get_template_directory_uri() is pretty sparse on details. The codex.wordpress.org entry for get_template_directory is much clearer and the two functions are closely related (the former returns a url, the latter returns a filesystem path) so you can infer what one does from the other.

From the codex entry for get_template_directory:

Retrieves the absolute path (eg: /home/user/public_html/wp-content/themes/my_theme) to the directory of the current theme.

If a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory.


Also, in the future, please try to copy and paste the code into the questions body instead of screenshoting it; it makes it easier for us to copy, edit and answer 🙂