最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to remove default jquery and add js in footer?

programmeradmin0浏览0评论

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.

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.

Share Improve this question edited May 25, 2015 at 9:15 fuxia 107k38 gold badges255 silver badges459 bronze badges asked May 25, 2015 at 5:17 codercoder 3932 gold badges3 silver badges9 bronze badges 2
  • possible duplicate of How to add a javascript snippet to the footer that requires jQuery – Robert hue Commented May 25, 2015 at 5:30
  • Note: It is generally not recommended to remove/replace the jQuery version bundled with WordPress core. – Nicolai Grossherr Commented May 25, 2015 at 10:24
Add a comment  | 

3 Answers 3

Reset to default 28

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/ajax/libs/jquery/1.10.2/jquery.min.js", false, null);
   wp_enqueue_script('jquery');
}

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' );
?>

Add Jquery In Footer In Wordpress

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' );
?>

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');
}
发布评论

评论列表(0)

  1. 暂无评论