如果jquery没有使用注册或排队,您可以运行一些检查并将其排队wp_script_is
function bootstrap_script_init() {
// Check to see if jQuery is registered, if not, register it.
// You can use the local version of WP\'s jQuery if you want instead of Google\'s API.
if ( !wp_script_is( \'jquery\', \'registered\' ) ){
wp_register_script( \'jquery\', \'//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\', array(), \'3.2.1\', true );
}
// Check to see if it is enqueued, if not, enqueue it.
if ( !wp_script_is( \'jquery\', \'enqueued\' ) ){
wp_enqueue_script( \'jquery\' );
}
wp_register_script(\'bootstrap\', get_template_directory_uri(). \'/js/bootstrap.min.js\', array(\'jquery\'), \'3.3.7\', true);
wp_enqueue_script(\'bootstrap\');
}
add_action( \'wp_enqueue_scripts\', \'bootstrap_script_init\' );