I’m making a framework parent theme and in the parent functions.php
, I want to register all the possible js files I use frequently and if I want it to load it, in the child functions.php
I just have to use wp_enqueue_script()
.
But it doesn’t work…
Any clue why?
The child functions.php file loads before the parent functions.php, so you’re registering them after enqueueing them. Try enqueueing the scripts on a hook, like
'after_setup_theme'
instead.It’s bad form to split your code like that. You should always have your functions and the hooks that call them located in the same location to make it easier to debug.
That said, if you place your
wp_enqueue_script()
calls in the parent theme’sfunctions.php
file, do things work like they’re supposed to? If not, there might be something else going on … and we’d need to see your code to diagnose and fix it.