虽然其中一个答案已经被接受,但我觉得以下技术可能对某人有所帮助.
在Plugin PageOR处包含以下代码function.php
function include_jQuery() {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('init', 'include_jQuery');
Run Code Online (Sandbox Code Playgroud)
绝对可以使用任何有意义的函数名称代替include_jQuery.
或者,您可以使用以下代码:
function include_jQuery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
wp_enqueue_script('jquery');
}
}
add_action('init', 'include_jQuery');
Run Code Online (Sandbox Code Playgroud)
最后,作为一般规则,除非您使用了其中一个快捷方式$,jQuery否则不应使用该变量.以下是如何快捷方式jQuery安全使用变量的示例:$
jQuery(function ($) {
/* You can safely use $ in this code block to reference jQuery */
});
Run Code Online (Sandbox Code Playgroud)
您也可以从我亲自学习上述技术的地方获得此链接.非常感谢Ericm Martin!
| 归档时间: |
|
| 查看次数: |
16437 次 |
| 最近记录: |