Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

add_action('wp_print_scripts','add_js_vars');
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.