What to do when jQuery doesn’t work in WordPress

Lately I’ve been gearing up to include some dynamic financial tools in my blog.  Making my custom code play nice in php requires jQuery, something I cover in detail in another jquery tutorial.  But I’ve found that even jQuery breaks sometimes.  Fortunately, there are only a few things that can go wrong:

  1. jQuery isn’t installed in wordpress. Although jQuery is now included in all wordpress installations, jQuery occassionally gets dropped from updates (this is more likely to happen if you use an ftp client to process your upgrades).  To make sure jQuery is loaded, double-check that the jquery folder is included in /wordpress/wp-includes/js/.
  2. Your code isn’t updating because it’s being cached. In the default installation of wordpress, this isn’t a problem, but if you’re using a caching program such as WP Super Cache, you should go into your settings folder and turn off the cache until you’re done updating your code.  If you’re a performance wonk like me, you may also have client-side caching enabled in your htaccess folder.  This is an excellent feature, and a pain in the butt to turn off and on, so the best way to fix this problem is just to select “clear private data” within your browser.
  3. The jQuery library isn’t loading. This happened to me, and I’m still not sure how (please comment if you have a clue).  But it’s easy to fix.  Just add the following tag to templates/header.php in your theme folder:
1
2
<script src="/wordpress/wp-includes/js/jquery/jquery.js" type="text/javascript">
</script>

Those are the big errors to check first.  If jQuery still isn’t working, check your functions against the jQuery library.  A good cheat sheet can also be useful.

  • Print
  • PDF
  • email
  • Facebook
  • Twitter
  • Digg
  • Google Bookmarks
This entry was posted in Technology. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Clark
    Posted 11 Oct 2009 at 11:54 pm | Permalink

    Thank you so much. I’ve literally been trying to fix this for the past 10 hours. I had no idea why a plugin wasn’t working. Thank you again!!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Switch to our mobile site