WordPress的这个功能将自定义脚本和样式应用于主题有什么问题吗?



这是我在函数中添加的函数.php但它不起作用。这段代码有什么问题吗?

function custom_scripts_css_with_jquery()
{
//wp_register_script( 'Bootstrap_min_js','//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' );
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');
wp_register_script( 'select2jquery', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js');
wp_register_style( 'select2mincss', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css');
// For either a plugin or a theme, you can then enqueue the style:
wp_enqueue_script( 'select2jquery' );
wp_enqueue_script( 'jquery' );
wp_enqueue_style( 'select2mincss' );
//wp_enqueue_script( 'Bootstrap_min_js');
}
add_action( 'wp_enqueue_scripts', 'custom_scripts_css_with_jquery' );

使用 beloe 函数

function custom_scripts_css_with_jquery()
{
// Deregister the included library
//wp_deregister_script( 'jquery' );
// Register the library again from Google's CDN
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', array(), null, false );
wp_register_script( 'select2jquery', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js', array(), null, false );
// Register the style like this for a theme:
wp_register_style( 'select2mincss', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css', array(), '4.0.3', 'all' );
// For either a plugin or a theme, you can then enqueue the style:
wp_enqueue_style( 'select2mincss' );

}
add_action( 'wp_enqueue_scripts', 'custom_scripts_css_with_jquery' );

相关内容

最新更新