According to the WordPress codex, the wp_head(); should be located right before the closing head tag.
When I insert the code after the wp_head(); it works. But when I insert it before wp_head(); as it should be, it results in a blank space. Look at the picture to see what Firebug sais when it goes blank.
This is the code:
<link rel="stylesheet" href="flexslider/flexslider.css" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="flexslider/jquery.flexslider.js"></script>
<script type="text/javascript" charset="utf-8"> $(window).load(function() {
$('.flexslider').flexslider({
slideshow: true,
controlNav: false,
directionNav: false, animation: "slide", slideshowSpeed: 4500, animationDuration: 600,
}); }); </script>
Firebug:
How come is that? Any ideas?
Yes,
wp_head()
should be before</head>
, but your javascript code should be before</body>
.Javascript is always recommended to be put in the end of the DOM. In case that is not possible (e.g. specific javascript must be loaded before the DOM, which does not seem to be true in your case) , put it before
</head>
and afterwp_head();
EDIT
Also, what I noticed in your case is that your main script might not be accessible if you are using SEO friendly urls. You should specify absolute url.