WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a functions.php inside my theme folder. The first line of functions.php is

require_once 'custom.php';

inside custom.php I have this simple code:

function add_js_vars(){ 
    //some stuff here

The problem with the code above is that add_js_vars is not executed. If I move add_action('wp_print_scripts','add_js_vars'); inside themes functions.php everything works fine. I'm not able to understand what's the problem. Any ideas? Thanks for your help.

share|improve this question
Can't give any advice without any code. Please copy and paste your code somewhere pastebin.com preferably. – Kevin Langley Jr. Jan 4 '12 at 15:32
No, please post it here in case the pastebin link expires. @cardy_web And please use code formatting. We take the time to read and maybe answer and you take the time to make this worth it. – kaiser Jan 4 '12 at 17:07
up vote 0 down vote accepted

Just wrap you include(s) in a function and hook it to after_setup_theme hook.

share|improve this answer
Thanks a lot. Works great! – cardy Aug 2 '12 at 10:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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