推奨される方法を使用して、Wordpress の子テーマに jQuery とカスタム スクリプト ファイルを含めようとしています。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' );
?>
これは 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
ありがとう。