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.

So I'm trying to link in a javascript file the right way, by using this:

--functions.php--
function custom_scripts() {
    wp_register_script('myscript','/backdrop.js',array('jquery'));
    wp_enqueue_script('myscript'); 
    console.log("test - inside custom_scripts"); 
}
add_action( 'wp_print_scripts', 'custom_scripts');

I don't see the console logs in the chrome console window, and I'm not sure if I should see them or not. However I see that one of my files cannot be found: /backdrop.js?ver=3.5.1. The directory is correct but the ?ver=3.5.1 obviously doesn't match up. Since I'm manually registering the script in a custom functions.php, why does it still do this?

share|improve this question
    
where is your script exactly? in your theme directory, or the root of your domain? –  Milo Apr 24 '13 at 1:45
add comment

1 Answer

console.log() is a JavaScript function. You cannot use it in PHP. Add that to your JavaScripts.

The version parameter should not affect the file access. But you can remove that parameter and see if it works then. If it does, your server configuration needs further inspection, because it should also work with the version.

share|improve this answer
    
Oh lol, that's what you get when you are learning 2 languages simultaneously >_> And wow, that did the trick. thank you! –  blake miller Apr 24 '13 at 2:23
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.