Javascript (Including JQuery) not loading in Custom Template
-
Hi,
I’ve done a lot or reading to ensure that I am including my JQuery and custom javascript to my custom theme without blowing up other plugins…The site that I am turning into a wp-theme needed this javascript:
<script src="https://www.google.com/jsapi?key=ABQIAAAABZGjjDpjmjbzLaNWBpdrWhRYfwzT-VuwidSQZM_JU-MUSrbEShR1efDdxuqpWPsjsfs1V_59FUTrxg" type="text/javascript"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript" src="./scripts/cycle/jquery.cycle.all.min.js"></script> <script type="text/javascript" src="./scripts/cycle/aaro_cycle.js"></script> <script type="text/javascript" src="./scripts/cycle/aaro_contest_cycle.js"></script> <script type="text/javascript" src="./scripts/jquery.hoverIntent.minified.js"></script> <script type="text/javascript" charset="utf-8" src="./scripts/mega_menu.js"></script>
I started off pretty simple I just wanted to see if I could load the version of jQuery I need plus on jQuery plugin and one custom javascript so after researching it seemed this was the best way?:
<?php function loadCustomScripts(){ wp_deregister_script('jquery'); wp_register_script('jquery', ("http".($_SERVER['SERVER_PORT'] == 443 ? "s" : "")."://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"), false, '1.4.3'); wp_enqueue_script('jquery'); wp_deregister_script('jquery.cycle.all.min'); wp_register_script('jquery.cycle.all.min', ("./scripts/cycle/jquery.cycle.all.min.js")); wp_enqueue_script('jquery.cycle.all.min'); wp_deregister_script('mega_menu'); wp_register_script('mega_menu', (get_bloginfo("stylesheet_directory") . "/scripts/mega_menu.js")); wp_enqueue_script('mega_menu'); } add_action('wp_enqueue_scripts','loadCustomScripts'); ?>
But this does not load any of the scripts defined in the php function loadCustomScripts(). I know that a normal <script> in the <head> section loads as my google api key loads. I do not want to load the other scripts this way as it most certainly will later cause conflicts.
Any ideas on what might be happening and why these scripts are not loading. Your help is appreciated on this one as this is my first forray into custom javascript in a theme and my second theme ever ??
- The topic ‘Javascript (Including JQuery) not loading in Custom Template’ is closed to new replies.