Getting external javascript to work in my theme header
-
I have added a “slider” javascript to the header of my website conversion that works correctly in a straight HTML version (non WordPress). Now I’m adding this JS slider to the WP site.
Per the codex (http://codex.wordpress.org/Using_Javascript), I set the call for the JavaScript, or the script itself, in the head of the header.php template file “between the meta tags and the style sheet link, no differently than you would if you were using JavaScript in any HTML page.” SIMPLE. DONE.
Unfortunately, this did not work, so then I recoded the script per the codex recommendation as follows:
<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/pathto/yourscript.js”></script>
SIMPLE. DONE.
Unfortunately, the script still does not work. Just to be sure, I double-checked that the scripts have been uploaded to the corresponding directories and, yes, they are there.
This is my first time adding in an external JS to a customized WP theme, so any help in resolving this is appreciated. Here’s the work in question:
__________1) my temp URL: http://184.173.196.198/~kwj1966/wp/
(the initial slider screen resides in the correct container while the additional slides are displaying down the page since the JS is not working)
__________2) my script reference within <head> tags as follows:
<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/js/libs/jquery-1.6.2.min.js”></script>
<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/js/libs/jquery.easing.1.3.min.js”></script>
<script type=”text/javascript” src=”<?php bloginfo(‘template_url’); ?>/js/royalslider/royal-slider-6.0.min.js”></script>
NOTE: These three JS files are in the referenced directories.
__________3) my script reference in the html as follows:
<script>
$(document).ready(function() {
$(‘#myContentSlider’).royalSlider({
directionNavEnabled: true,
directionNavAutoHide:true,
welcomeScreenEnabled:false,
imageAlignCenter:true
});
});
</script>
__________I don’t know what else to modify or edit. What am I missing? Any help is appreciated. Best, Kevin
- The topic ‘Getting external javascript to work in my theme header’ is closed to new replies.