I'm trying to replace "hardcoded" calls in my header.php by registering and enqueueing them in functions.php. JQuery 1.8.3 loads as desired, but the other scripts don't. Here's what I'm using:
function puckpros_load_my_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');
wp_enqueue_script('jquery');
wp_register_script('menu', get_stylesheet_directory_uri().'/js/menu.js', array('jquery') );
wp_enqueue_script('menu');
wp_register_script('kwicks', get_stylesheet_directory_uri().'/js/jquery.kwicks.js', array('jquery') );
wp_enqueue_script('kwicks');
wp_register_script('equalheights', get_stylesheet_directory_uri().'/js/jquery.equalheights.js', array('jquery') );
wp_enqueue_script('equalheights');
}
add_action('wp_enqueue_scripts', 'puckpros_load_my_scripts');
It's a child theme, so I'm using get_stylesheet_directory_uri() and the paths to the files are correct.
I'm sure it's something simple, but I can't see what I'm doing wrong.
Thanks.
EDIT
As suggested below by Chip, I changed my functions.php to eliminate the call to jquery and remove the register calls. I now have:
function puckpros_load_my_scripts() {
wp_enqueue_script('kwicks', get_stylesheet_directory_uri().'/js/jquery.kwicks.js', array('jquery') );
wp_enqueue_script('equalheights', get_stylesheet_directory_uri().'/js/jquery.equalheights.js', array('jquery') );
wp_enqueue_script('wslaunch', get_stylesheet_directory_uri().'/js/wsLaunch.js', array('jquery') );
}
add_action('wp_enqueue_scripts', 'puckpros_load_my_scripts');
But my script equalheights won't execute, tho it does if I load in directly in the header like this:
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.kwicks.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.equalheights.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/wsLaunch.js"></script>
Now I'm stumped again. I'd like to "do it right" and enqueue, but I can't get it to work.
Thanks for any help.
get_header()
call and change your question :) – kaiser Oct 29 '13 at 23:05