使用函数添加js文件。php
function add_theme_scripts() {
wp_enqueue_script( \'script\', get_template_directory_uri() . \'/js/script.js\', array ( \'jquery\' ), 1.1, true);
}
add_action( \'wp_enqueue_scripts\', \'add_theme_scripts\' );
或
//if you want to add script in plugin use this code in plugin:
function yourScript() {
wp_register_script( \'script\', plugins_url(\'js/jqueryfile.js\',__FILE__),array(\'jquery\'),\'1.1\', true );
wp_enqueue_script(\'script\');
}
add_action( \'admin_enqueue_scripts\', yourScript);