06th May2016
Author: Gyro

WP Lightbox stopped working – jQuery version the culprit.

I just spent a while trying to figure out why a lightbox stopped working on a friend's WP site.

Supposedly nothing had changed… and looking at the code, everything looked ok.

After some trial and error, I finally figured out that the issue was with the jQuery version, the site was loading version 1.2.1, which apparently does not work with the lightbox plugin. I tried jQuery version 2.0.2, but that seems to have been too much, so I finally settled on jQuery version 1.7.1 which seem to work well with any jQuery script junning on his site.

An easy way to manually set this jQuery version in WordPress is adding some code to the theme's functions.php:

function modify_jquery_version() {
if (!is_admin()) {
wp_deregister_script(‘jquery');
wp_register_script(‘jquery', ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', false, ‘1.7.1');
wp_enqueue_script(‘jquery');
}
}
add_action(‘init', ‘modify_jquery_version');

Just change the version numbers 1.7.1 to the one you need.

173

Keep Me Going
Your Name / Website:
Did you like my post? Buy me a Bitcoffee! 14JX52Li7zTKbyQv2omw4tvu6Bi1KzfHNW



Leave a Reply

Your email address will not be published. Required fields are marked *

What is 6 + 9 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)