Reuse javascripts from plugins within the theme

I am trying to reuse the bxslider javascript that gets installed in a plugin.

The page I am working on has this basic structure:

SLIDER <– configured in a plugin

SLIDER OF WOOCOMMERCE OFFERS <– list of offers comes from woocommerce

SLIDER <– configured in a plugin

I am actually using bxslider.
The woocommerce gives me actually a list of offers, so I’d like them to trigger bxslider for them. with a simple

 $('.products').bxSlider({
    });

So i am trying in the functions.php

wp_enqueue_script( ‘main’, get_template_directory_uri() . ‘/js/main.js’, array(‘jquery’,’bxslider’), ‘20151215’, true );

Actually I only get a .bxslider() is not a function javascript ERROR.

I also tried to include bxslider additionally as a javascript including dependencies, but the error stays the same…

1 Answer
1

var j = jQuery.noConflict();

    j(document).ready(function() 
    {
       j('.products').bxSlider({
       });

    });

Did the trick!
& including bxslider.js in wp_enqueue with jquery dependency before the main

Leave a Comment