Grow your CSS skills. Land your dream job.

Can’t get jquery to load in my WordPress theme. Please help.

  • # April 17, 2009 at 11:56 am

    It’s driving me nuts!
    This is what I’ve got in my theme header.php:

    Code:
    < ?php wp_enqueue_script('jquery'); ?>

    < ?php wp_head(); ?>

    But doesn’t seem to work?!

    Is there anyway to test if the jQuery library is loaded… something equivalent to phpinfo.php ?

    # April 17, 2009 at 12:07 pm

    I always use the google hosted version and never have a problem. Just add this to your header before you call your js file:

    Code:
    # April 18, 2009 at 12:16 am

    Really looks like you got that correct. Live link would be the only way we could see what’s going on and help.

    pab
    # April 18, 2009 at 3:22 am

    you can try this

    <script type="text/javascript" src="<?php bloginfo(‘template_directory’); ?>/js/jquery.js"></script>

    # April 18, 2009 at 4:30 pm
    "chriscoyier" wrote:
    Really looks like you got that correct. Live link would be the only way we could see what’s going on and help.

    It’s still on my dev server at the mo.

    Actually after a bit more testing it turns out that the lib is loading and the problem appears to be with the jQuery plugins that I’m using (or maybe how they’re called). Some work and some don’t in WP, but all work in static test HTML.

    Example:

    To try and get my head ’round jQuery, I’ve followed this tut:
    http://net.tutsplus.com/tutorials/javas … esomeness/

    It work’s fine in a straight HTML page, so now I’m trying to use it with WP.

    In WP I’ve got the following immediately before </head>:

    Code:

    I also tried enqueueing the "bettertooltip.js" after jquery ( before the wp_head(); ), but that doesn’t work either. Like this:

    Code:
    < ?php wp_enqueue_script('jquery'); ?>
    < ?php wp_enqueue_script('bettertooltip', 'http://cdn.css-tricks.com/wp-content/themes/my-theme/js/bettertooltip.js', array('jquery')); ?>

    < ?php wp_head(); ?>

    Thanks for the feedback so far, much appreciated!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".