, , , ,

If you need to call a javascript file from a wordpress template you can use this little bit of code to cue it up and inject it in the head only when it’s needed.

In your functions.php file use something like this:

if (!is_admin()) {

Here I’m using it to insert a link to the javascript files for jcarousel lite and jquery (already included in WordPress)  and only displaying it on pages other than admin ones.  The wp_enqueue_script hook can be used inside plugins too if you need to make sure a template has the correct js file loaded.