将jQuery添加到Underscores(_s)WordPress主题的最佳方法是什么?

这似乎是一个基本的东西,但我不确定如何将jQuery(使用CDN)添加Underscores wordpress启动器主题中.我做了一些搜索,但没有找到任何东西,所以我希望有人能在这里找到答案吗?

先感谢您!

解决方法

最好的方法是在你的下划线创建主题functions.PHP文件中使用wordpress功能 wp_enqueue_script().

找到函数< THEME_NAME> _scripts(其中< THEME_NAME>是从Underscores网站生成主题名称),并在< THEME_NAME> _scripts函数下(在任何其他wp_enqueue_script之前)下面添加下面的代码

// deregister default jQuery included with wordpress
wp_deregister_script( 'jquery' );

$jquery_cdn = '//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js';
wp_enqueue_script( 'jquery',$jquery_cdn,array(),'2.2.4',true );

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...