Script in header ignored

  • Hi,
    I have been trying to solve this for days.
    I have inserted jQuery into the header section with this plugin. The problem is that WordPress ignores all of this code. As if it is not there. Indeed the website appears the same with or without code! Why would this be?

    DO I need to add some code the functions.php. I have tried many variations of this with no effect. Do I need to do something else? If yes what?!

    I am running the theme of 2011. Is this the problem? I do not see why it would be.

    Simply I am asking how I can get my website to run jQuery.

    All help very much appreciated

    JQuery code below if it makes a difference, as you can see I am simply trying to do a sollover for a couple of images. Before I try some other features once I get WordPress to notice my code.

    ```<script type="text/javascript"></p>
    <p>jQuery( document ).ready( function( $ ) {<br />
       $('#gallery img').each(function() {<br />
       var imgFile = $(this).attr('..../blog/wp-content/uploads/_images/unknown.jpg');<br />
       var preloadImage = new Image();<br />
       var imgExt = /(\.\w{3,4}$)/;<br />
       preloadImage.src = imgFile.replace(imgExt, '_h$1');<br />
         $(this).hover (<br />
            function() {<br />
              $(this).attr('src', preloadImage.src);<br />
         },<br />
           function() {<br />
             $(this).attr('src', imgFile);<br />
            }<br />
         ); // end hover<br />
       }); // end each<br />
    }); // end ready<br />


  • Hello,

    The issue is not related to the plugin. I suggest you to use for these type of questions. You will learn a lot there.

    BTY, You will first need to check if jQuery is loaded by your theme or any of the plugins. Because only then you could run jQuery script by simply inserting the code.

    Secondly I don't think a theme just developed in 2011 is an issue as long as it is compatible with latest WP or still getting updates.

    I hope this will put you in right direction.

    PS: You might need to enable script debugging for possible errors. Just Google it or visit

    PPS: Always backup your site while making changes to ensure site safety or in case you somehow broke it.

  • Thanks for the info...I have no idea f this is the plugin or code. The code is pretty far as I can see correct. (can't say for sure as WP not running it!) SO I thought it must be the plugin. So onto week 2 of trying to figure the ONE issue out!

  • Hello,

    I have just visited your site which you mentioned on The site do not enqueue jQuery:

    The following links might be helpful for you.

    I don't know why you have added jQuery 3 times. Read the above links for details.


  • This post is deleted!

Log in to reply