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?

2 Answers 2


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.

  • Nice gonna tcheck this right now!!!
    – Eduplessis
    Aug 23, 2010 at 21:00
  • Thanks working perfectly... but I put it on the 'init' hook
    – Eduplessis
    Aug 23, 2010 at 21:08
  • I'll still advise against splitting things up like this - registering scripts in the parent file and enqueuing them in the child file might work for your uses, but it makes it more difficult on developers who come along later and want to build a new child theme - they have to reproduce all of you enqueuing code to make it work. A child theme is supposed to modify the parent, not reproduce the parent's original child theme ...
    – EAMann
    Aug 23, 2010 at 21:10

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's functions.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.

  • In general I agree with your comments about bad form but I think it doesn't apply in this use-case. What he @Eduplessis is doing in his parent theme is essentially the same that WordPress does in wp_default_scripts() in /wp-includes/script-loader.php; i.e. he's registering his custom scripts using wp_register_script() so his child themes need only call the simpler form of wp_enqueue_script() instead of having to specify the script's full file name and path from the parent's theme directory. FWIW. Aug 23, 2010 at 23:18
  • I agree that the pattern has its uses ... but I'm coming from the background of having to debug poorly documented child themes and trying to help clients figure out when different functions are called on their site. Since wp_register_script and wp_enqueue_script work together, having them in different files can make it incredibly hard to track things down later.
    – EAMann
    Aug 24, 2010 at 1:34
  • thanks for your comments. A themes framework without any documentation is bad... or any project in gen. but since this themes framework it's only to speed up my developpment and I always make a little doc... i think it's the right choice to put all register all my script in my parent and the specific load in child... exactly like WordPress do with all js included by default.
    – Eduplessis
    Aug 29, 2010 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.