How to load specific java script on specific page?
-
I am developing my first site using wordpress. I have pretty much finished the site, expect one problem with java script conflicting.
what I am having now is that all my java script files are imported in my header.php, so jquery is loaded on each single page.
This is my current code<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/validate_trigger.js" ></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/custom.js"></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.validate.js" ></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/easySlider1.5.js"></script>
What I am trying to archive is that jquery files are only loaded on certain pages where I need them.
For example, I have a contact.php page, where I have jquery validator.
how do I call my jquery.validate.js without putting my code inside header.php, but contact.php?
I spent 3 hours trying to get wp_enqueue_script working, but it just doesn’t!
In my contact.php, it starts with<?php wp_enqueue_script('jquery-1.3.2.min', 'wp-content/themes/vono/js/jquery-1.3.2.min.js'); ?> <?php wp_enqueue_script('custom', 'wp-content/themes/vono/js/custom.js'); ?> <?php get_header(); ?> <?php get_sidebar(); ?>
But it does not seem to work.
Am I on the right track here?
I am a newbie, I am sure this can be easily fixed, thanks in advance for anyone who can help.
- The topic ‘How to load specific java script on specific page?’ is closed to new replies.