I am getting an issue when adding the jQuery in fucntions.php. When adding it, some stuff stop working like ACF Datepicker, Wordpress Admin with JS dropdown also stop working IDK what happen but the issue when adding the jquery everything on related to js is suddenly stop working..
please help me.
<?php
function Load_CSS() {
wp_register_style('main', get_template_directory_uri() . '/css/main.css', array (), false, 'all');
wp_enqueue_style('main');
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Lora&family=Roboto:wght@900&display=swap',array(), null );
wp_register_script('script', get_template_directory_uri() . '/js/script.js', array('jquery'),'1.0.0', true);
wp_enqueue_script('script');
wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v6.1.1/css/all.css',array(), null );
}
add_action('wp_enqueue_scripts','Load_CSS');
// Load External JS & CSS
wp_register_script('x', 'https://code.jquery.com/jquery-3.6.3.min.js', null, null, true );
wp_enqueue_script('x'); <-- This is the jQuery im talking about.
wp_register_script( 'Slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js', null, null, true );
wp_enqueue_script('Slick');
CodePudding user response:
your website is probably loading multiple versions of jquery beacuse you have just registered a new one with a different name. Ideally you should deregister the default one and register a new one:
wp_deregister_script('jquery');
wp_register_script('jquery', "https://code.jquery.com/jquery-3.6.3.min.js", false, null);
wp_enqueue_script('jquery');
