I know that wordpress ships with jquery. I have built my site first in html and every script that I have running in the html version works fine running version 1.4.2. I included this same jquery script and now one of my features don't work. This is how I am loading jquery into the head of my site

function register_savior_scripts(){
    wp_enqueue_script('prettyPhoto', get_template_directory_uri().'/js/jquery.prettyPhoto.js', array('jquery'));
    wp_enqueue_script('slider', get_template_directory_uri().'/js/coin-slider.min.js', array('jquery'));
add_action('wp_head','register_savior_scripts', 0);

If I check the head, I see the script. It looks like this

<script type='text/javascript' src='full path removed/js/jquery.js?ver=3.4.1'></script>

It's not version 3.4.1. Not sure that matters. The script that it is running I put directly into the head and is this code

            if($(this).hasClass('down-arrow')) {
            else {

Is there a better way to load the script above into the head? Do you know why it would work on the html but not wordpress?

All it does is slide a div up or down to hide it if you press a link.

1 Answer 1


you're deregistering jquery, then registering it under the handle js-scripts, but then specifying the jquery handle as a dependency for your other scripts. also, use the wp_enqueue_scripts hook for wp_enqueue_scripts function, not wp_head. the appended version doesn't matter, but you can pass null as version parameter to get rid of it completely if you want.

  • well, I made the changes you suggested. Those were good ideas. I found that the reason the code isn't working is because of other scripts I have loading in the head section of my site. This is weird because it works just fine on the html version. Why would the WordPress version be any different?
    – Jamie
    Commented Aug 16, 2012 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.