I want to remove default jQuery, because I am adding new or latest jQuery. Also I want include some js in my footer. How can I do that?
I want to add another different js like a slider js or css in my footer.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
This will do the trick when added to your functions file:
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null);
wp_enqueue_script('jquery');
}
Method 2
I am searching I get one blog here I get two different code. one for
Remove Default Jquery In WordPress
Here I am the same code for below
<?php
function myphpinformation_scripts() {
if( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_stylesheet_directory_uri() . '/js/jquery.min.js', false );
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'myphpinformation_scripts' );
?>
here I know how to add js in WordPress in the footer. I think removing default jquery and add js in the footer in WordPress is a different question.
Here I can found that
<?php
function myphpinformation_scripts() {
wp_enqueue_script( 'scroll', get_stylesheet_directory_uri() . '/js/script.js',array('jquery'),'',true);
}
add_action( 'wp_enqueue_scripts', 'myphpinformation_scripts' );
?>
Method 3
Remove WordPress default jQuery from front end
We can remove default wordpress jQuery from the frontend so that to avoid conflict with the jQuery in the theme. In order to remove the default jQuery add the following code in the function.php file in the theme folder.
add_action('wp_enqueue_scripts', 'no_more_jquery');
function no_more_jquery(){
wp_deregister_script('jquery');
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0