Php Wordpress javascript文件调用返回奇怪的路径
我正在尝试使用推荐的方法Php Wordpress javascript文件调用返回奇怪的路径,php,javascript,jquery,html,wordpress,Php,Javascript,Jquery,Html,Wordpress,我正在尝试使用推荐的方法wp\u enqueue\u 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' ) )
wp\u enqueue\u 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' );
?>
这显然是错误的。我不认为这与在本地主机上开发(使用MicrosoftWebMatrix 2)有任何关系,但更重要的是Wordpress破译路径的方式?我不确定
我怎样才能让它吐出正确的路径
twentywelve-child/js/customScripts.js
谢谢。试试这个插件的url('js/customScripts.js',\uuuu文件)
而不是插件的url('/js/customScripts.js',\uu文件)
(删除第一个斜杠)
看:
twentywelve-child/js/customScripts.js