【发布时间】:2014-08-10 20:14:57
【问题描述】:
我正在尝试在我的网站主题中添加两个 JS 文件:
- js/jscripts.js
- js/bootstrap-hover-dropdown.js
我正在使用的代码:
function wptuts_scripts_with_jquery()
{
// Register the script like this for a plugin:
wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ), array( 'jquery' ) );
// or
// Register the script like this for a theme:
wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js', array( 'jquery' ) );
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_jquery' );
通过使用这个功能,我只能添加一个 JS 文件,我如何添加第二个 JS 文件。我是 wordpress 和 PHP 的新手。需要帮忙!! :)
【问题讨论】:
-
这些js文件在哪里?在主题 js 文件夹中?
-
真的吗?您刚刚直接从 a tutorial 复制并粘贴了它,它准确地解释了如何做您所要求的!
标签: javascript php jquery wordpress