在wordpress中添加外部javascript文件 [英] Add external javascript file in wordpress
本文介绍了在wordpress中添加外部javascript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 wordpress 主题中添加多个外部 javascript 文件,我找到了添加一个文件的代码,但我需要添加更多 javascript 文件.我该怎么做?
I want to add more than one external javascript files in wordpress theme, I have found code for adding one file, but I need to add more javascript files. How can I do it?
function wpTan_scripts() {
wp_register_script('app', '/js/app.js', false);
wp_enqueue_script( 'app' );
}
add_action('wp_enqueue_scripts', 'wpTan_scripts');
推荐答案
您可以添加任意数量的脚本.
you can add as many scripts as you want.
function themeslug_enqueue_script() {
wp_enqueue_script( 'jquery-v-2', 'http://code.jquery.com/jquery-2.1.3.min.js', false );
wp_enqueue_script( 'mycustomJs', 'file_name.js', false );
// here you can enqueue more js / css files
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );
这篇关于在wordpress中添加外部javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文