强制特定版本的jQuery-Wordpress [英] Force specific version jquery - Wordpress
问题描述
我一直在试图迫使我的wordpress网站使用特定版本的jquery.由于wordpress的最新更新要求用户使用1.9版,因此我的菜单栏现在无法正常工作.在找到此升级的修复程序之前,我想强制我的网站使用jquery的早期版本.为此,我已经尝试了两件事:
I have been trying to force my wordpress website to use a specific version of jquery. Since the last update from wordpress obligated users to use version 1.9, my menu bars are now not working correctly because of this. Until I find a fix from this upgrade, I would like to force my website to use a previous version of jquery. To this effect I have already tried two things:
-
我编辑了functions.php文件以添加一些代码.我是通过以下链接获得的:( http://www.wpbeginner.com/wp-themes/replace-default-wordpress-jquery-script-with-google-library/)
//Making jQuery Google API
function modify_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.1/jquery.min.js', false, '1.8.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'modify_jquery');
我编辑了default-options.php文件,在其中说'jquery'=> true的地方,我将其更改为false.
I edited the default-options.php file and where it said 'jquery' => true, I changed it to false.
但是,这些选项都不起作用,我的网站仍然加载1.9.1版的jquery.该网站的链接是www.fiestacolegial.com
However, none of these options have worked and my website still loads version 1.9.1 of jquery. The link to the site is www.fiestacolegial.com
请让我知道如何强制执行先前版本的jquery或进行其他调整以修复未加载的子菜单.
Please let me know what I can do to force a previous version of jquery or another tweak to fix the submenus not loading.
谢谢!
推荐答案
因此,在尝试了上述选项后,它不起作用.但是后来我从另一个网站上找到了此代码,它成功了.
So after attempting the options mentioned above it didn't work. But then I found this code from another website and it did the trick.
您需要将此代码添加到Them Functions(functions.php)中:
You need to add this code to the Them Functions (functions.php):
//jQuery Insert From Google
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") .
"://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
}
您还应该转到default-options.php,并在显示"jquery" => true的地方将其更改为false.
And you also should go to the default-options.php and where it says 'jquery' => true change it to says false.
也...在上面提供的代码中,它说1.7.1将其更改为所需的任何版本.就我而言,我需要1.8.1来与我的wordpress模板一起使用.
Also... in the code provided above, where it says 1.7.1 change it to which ever version you need. In my case I needed 1.8.1 to work with my wordpress template.
感谢所有对此答案做出贡献的人:)
Thanks to all that contributed to this answer :)
这篇关于强制特定版本的jQuery-Wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!