0

I'm trying to includ jQuery and my custom script file in a Wordpress Child theme using the recommended method wp_enqueue_script

<?php

function wptuts_scripts_with_jquery()  
{  
    // Register the script like this for a plugin:  
    wp_register_script( 'customScripts', plugins_url( '/js/customScripts.js', __FILE__ ), array( 'jquery' ) );  
    // or  
    // Register the script like this for a theme:  
    wp_register_script( 'customScripts', get_template_directory_uri() . '/js/customScripts.js', array( 'jquery' ) );  
    // For either a plugin or a theme, you can then enqueue the script:  
    wp_enqueue_script( 'customScripts' );  
}  
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_jquery' ); 

?>

This works fine including jQuery, but it spits out this path for my custom script.

http://localhost:15869/wp-content/plugins/C:/Users/Kyle/Documents/MyWebSites/TomWictor.com/wp-content/themes/twentywelve-child/js/customScripts.js?ver=3.5

This is obviously wrong. I don't think it has anything to do with developing on a localhost (using Microsoft WebMatrix 2) but more to do with the way Wordpress deciphers paths? I am not sure..

How can I get it to spit out the proper path?

twentywelve-child/js/customScripts.js 

Thanks.

1 Answer 1

1

Try this plugins_url( 'js/customScripts.js', __FILE__ ) instead of plugins_url( '/js/customScripts.js', __FILE__ ) (remove your first slash)

Look: http://codex.wordpress.org/Function_Reference/plugins_url

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.