I have some trouble with loading external javascript files inside my WordPress theme. Use the following markup:
<script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/custom.js" type="text/javascript"></script>
The above code is set inside the <head>
of my header.php
file of my WordPress theme.
Why is this not working? Or should I also use the following for link external scripts?
function my_scripts() {
wp_enqueue_script( 'my-sweet-script', get_bloginfo('template_directory') . '/script.js', array('jquery') );
}
Thank you. Casper