WordPress conflicts with Jquery causing strange behaviour

I’m new to WordPress and I’ve been following some instructions to get my theme working with Jquery and Bootstrap 4. When I look in the dev console it seems like Jquery is being loaded twice – WordPress loads the ones from google apis by default and my local version.

However, I’m getting weird behaviour on my FAQ page, my accordion pops open, then immediately closes when clicked. If I go to the dev console and block the URL for the google Jquery then everything works fine.

I followed these instructions to dequeue jquery and queue my own local version – https://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/. I still see the google version loading and still get the strange behaviour though.

function my_init()
{
if (!is_admin())
{
wp_deregister_script(‘jquery’);

// Load the copy of jQuery that comes with WordPress
// The last parameter set to TRUE states that it should be loaded
// in the footer.
wp_register_script(‘jquery’, get_template_directory_uri() . ‘/js/jquery-3.3.1.min.js’, FALSE, ‘3.3.1’, TRUE);

wp_enqueue_script(‘jquery’);
}
}
add_action(‘init’, ‘my_init’);

Read more here:: WordPress conflicts with Jquery causing strange behaviour

Leave a Reply

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