Posted By

adambundy on 08/24/11


Tagged

wordpress jquery


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

adambundy
logik42


WordPress Enqueue jQuery - Google CDN


 / Published in: PHP
 

  1. ------------------------------------------------
  2.  
  3. This must be inserted into the functions.php file:
  4.  
  5. function modify_jquery() {
  6. if (!is_admin()) {
  7. // comment out the next two lines to load the local copy of jQuery
  8. wp_deregister_script('jquery');
  9. wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1');
  10. wp_enqueue_script('jquery');
  11. }
  12. }
  13. add_action('init', 'modify_jquery');
  14.  
  15. ------------------------------------------------
  16.  
  17. This must be inserted into the header.php file (BEFORE WP_HEAD CALL!):
  18.  
  19. <?php wp_enqueue_script("jquery"); ?>
  20.  
  21. ------------------------------------------------
  22.  
  23. jQuery functions should be wrapped in this so that $ operator represents no-conflict (BELOW WP_HEAD):
  24.  
  25. <script type='text/javascript'>
  26. jQuery(document).ready(function($) {
  27.  
  28.  
  29. // $() will work as an alias for jQuery() which is noconflict mode inside of this function
  30. });
  31. </script>
  32.  
  33. ------------------------------------------------

Report this snippet  

You need to login to post a comment.