0
我使用的是推薦的方法wp_enqueue_script
WordPress的JavaScript文件調用返回奇怪的路徑
<?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');
?>
試圖includ jQuery和在WordPress的兒童主題我的自定義腳本文件,這工作得很好,包括jQuery的,但它吐出來這我的自定義腳本的路徑。
http://localhost:15869/wp-content/plugins/C:/Users/Kyle/Documents/MyWebSites/TomWictor.com/wp-content/themes/twentywelve-child/js/customScripts.js?ver=3.5
這顯然是錯誤的。我認爲這與在本地主機上開發(使用Microsoft WebMatrix 2)沒有任何關係,但更多的是與Wordpress解譯路徑的方式有關?我不確定..
我怎樣才能把它吐出正確的道路?
twentywelve-child/js/customScripts.js
謝謝。