WP_REGISTER_SCRIPT无法链接引导JS

时间:2019-11-17 作者:Fraser

这是我加载引导文件的函数。

function load_js()
{
    wp_register_script(\'bootstrap\', get_template_directory_uri() . \'/js/bootstrap.min.js\', \'jquery\', false, true );     
    wp_enqueue_script(\'bootstrap\');
}
add_action(\'wp_enqueue_scripts\', \'load_js\');
我希望这条路线能够:

http://site.test/wp-content/themes/themename/js/bootstrap.min.js

但实际上:

http://site.test/wp-content/themes/themenamejs/bootstrap.min.js

1 个回复
SO网友:wpdev

function load_js()
{
    wp_register_script(\'bootstrap\', get_template_directory_uri() . \'/js/bootstrap.min.js\', array(\'jquery\'), false, true );     
    wp_enqueue_script(\'bootstrap\');
}
add_action(\'wp_enqueue_scripts\', \'load_js\');
与一起使用array(\'jquery\') 而不是\'jquery\'

参考文献here.上面写着:使用数组。

相关推荐

在URL中插入“javascript:id(0);”

无论如何,我都不是Wordpress的初学者,但我完全被这个问题所困扰。我尝试了一系列备选方案,但没有任何结果(href=“\\;”,href=“\\35; void”等)。我需要“javascript:void(0);”作为HTML链接中的href属性。将其插入文本编辑器,轻弹到视觉对象,然后返回文本编辑器,使其消失。我已经阅读了一些关于它的信息(回复:esc\\u url),但似乎找不到修复方法。我有没有办法通过函数或脚本在Wordpress的页面上实现这一点?我试图生成的链接是:<a href