wordpress jquery version conflicts

Viewed 623

In Wordpress use hook wp_enqueue_script to override jQuery version but it does not work.And i need both jquery.

I want to add new jquery version for website customization.

But when i add new version of jquery the old version of jquery functionally not working

function.php:

function themeslug_enqueue_script(){
    wp_enqueue_script('child_theme_script_handle', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js',
        array( 'jquery' ), '3.2.1', true );
    wp_enqueue_script( 'my-great-script', get_stylesheet_directory_uri() . '/core/assets/js/multi-vendors.js', 
        array( 'jquery' ), '1.0', true );
}

add_action('wp_enqueue_scripts', 'themeslug_enqueue_script');

jQuery.js:

$(document).ready(function(){
    alert('Hello');
});

Some functionally is not working. For example, the slider.

2 Answers

You need to first de register you old version script and enqueue new the version. Please use this code to change the jquery version.

<?php  function modify_jquery() {
    if (!is_admin()) { 
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', false, '1.7.2');
        wp_enqueue_script('jquery');
    }
 }

add_action('init', 'modify_jquery'); ?>

Thanks Every one to give suggestion.

I put my code in custom.js file and It's work. There is no need to add new jquery.

Sorry to misguide you.

Related