【发布时间】:2018-01-01 20:11:48
【问题描述】:
我正在尝试向我的 WordPress 网站添加一个 javascript 文件,但该文件无法加载。这是我的 functions.php 文件中的代码。
function add_custom_script() {
wp_register_script('custom_scripts', get_template_directory_uri().'custom.js', array(),'', true);
wp_enqueue_script('custom_scripts');
}
add_action( 'wp_enqueue_scripts', 'add_custom_script' );
谢谢
【问题讨论】:
-
在
'custom.js'上添加/,因为get_template_directory_uri()返回的模板URL 没有尾部斜杠。
标签: javascript wordpress templates