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 have the exact same files (except for wp-config) running on a local server and a test server, and in my functions.php I have this:

    function len_scripts() {
        if (!is_admin()):
            wp_enqueue_script('jquery');
            wp_enqueue_script('thickbox');
        endif;
    } 
add_action('wp_print_scripts', 'len_scripts');

On my localhost, everything works fine and all files are happily working. But on the test server, somehow, thickbox never gets called, i don't get any errors on the console and Firebug Network tab simply doesn't know it was supposed to be calling that file.

thickbox.css gets called, jquery.js also. thickbox.js doesn't.

Any ideas why this might be?

EDIT:

  • len_scripts() is called on wp_print_scripts, so no big deal here - there are other enqueue functions that i left out, and they are all working as expected.

  • Firebug console does not throw any errors, in fact, it doesn't recognize thickbox.js at all, like if the function calling it was never there. It doesnt appear in the console, the DOM, or the Network tab. No mention, not even 404 (but the file is indeed there).

  • In my final markup i get the script tag for jquery, then the script tag for other .js files, but never for thickbox. I do get a link tag for thickbox.css though, along with my other .css tags.

share|improve this question
1  
Read: codex.wordpress.org/Function_Reference/wp_enqueue_script, quoting important part: "This function will not work if it is called from a wp_head or wp_print_scripts actions, as the files need to be enqueued before those actions are run." –  soulseekah Mar 9 '12 at 21:48
    
nevermind. Just found out that the theme was never calling wp_footer(); (wasn't me, i swear.) Thickboxs always goes on the footer. –  moraleida Mar 9 '12 at 21:55
    
@moraleida Move this to an answer and mark your question as answered. –  toscho Mar 9 '12 at 22:15

2 Answers 2

You don’t need to enqueue jQuery if you enqueue ThickBox already. See this answer for details.

thickbox.css gets called, jquery.js also. thickbox.js doesn't.

Lots of missing details:

  • When do you call the function?
  • Is there markup in the HTML output of your page? A script element for ThickBox?
  • If so, do you get a 404 for the URI? Does the thickbox script really exists on the remote site?
  • Any errors in your console output?

Update your question, fill in the details.

share|improve this answer
    
+1 for saying: check your details! It wasn't any of these, but it helped. :) –  moraleida Mar 9 '12 at 21:57
up vote 0 down vote accepted

Reposting comment as answer:

I came to find out that the theme was never calling wp_footer(); which was stupid of me not to check since i didn't write the whole theme. Thickbox always goes on the footer.

share|improve this answer

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.