问题
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');
回答1:
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' );
来源:https://stackoverflow.com/questions/28185526/add-external-javascript-file-in-wordpress