I’m working on my first child theme and I’m running into a lot of confusion with directories and child themes.
I won’t use my real website but I have made a directory in my cPanel dedicated to working on my theme which is at www.wp.example.com
Lets call the template testTemplate. I made a child template called testTemplate-child following the WordPress codex meaning I registered the parent theme in the child theme’s function.php
So wp.example.com loads the style from both the parent theme and the child theme which is desired. What it does not load is the javascript files I enqueued in my child theme’s functions.php file.
The confusing part is this, if I navigate to www.wp.example.com/testTemplate-child/ my javascript loads up and works.
I’m wondering if anyone can clear this up for me, why does my child’s function.php only work in wp.example.com/testTemplate-child.
It’s because your child’s theme function.php is added before parent’s function.php, that’s why you can’t override some options, also keep in mind that you’ll need to call
get_stylesheet_directory()
to get child’s theme path, because if you do another function, it will load parent’s path.Example to load a javascript file located a /js folder:
More info at: https://codex.wordpress.org/Child_Themes