jQuery plugin not working with wp_enqueue_script
-
I’ve tried to put jQuery Fancybox (http://fancyapps.com/fancybox/) on my WordPress website. As I tried to do this “the way it should be done”, using wp_enqueue_script, the script loaded, as I could see in my developer console. The plugin didn’t work however. The code I used in functions.php:
function kls_script_enqueue(){ wp_enqueue_script('jQuery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', array(), null, false); wp_enqueue_style('Fancybox_css', get_template_directory_uri().'/js/fancybox/jquery.fancybox.css'); wp_enqueue_script('Fancybox', get_template_directory_uri().'/js/fancybox/jquery.fancybox.js', array('jquery'), null, false); } add_action('wp_enqueue_scripts', 'kls_script_enqueue');In my developer console, I can see that jQuery as well as Fancybox are added. The plugin doesn’t work though. Makes you think that I didn’t call the plugin (right) or I forgot to add the .fancybox class to my images. But here it comes: if I hardcode the script in my header.php, the plugin does work. I can’t seem to figure out why this is. When using wp_enqueue_script, jQuery was loaded before Fancybox (as it should), so the problem shouldn’t be there.
The topic ‘jQuery plugin not working with wp_enqueue_script’ is closed to new replies.