Child theme scripts loading via wp_enqueue_scripts but not working
-
Hi. I’m new to theme development, using a child theme, and am having a problem replacing hardcoded script references with enqueued scripts (like all the advice I see says to do,)
If I do this in my header.php, the scripts load and work:
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery-1.8.3.js"></script> <script type='text/javascript' src='<?php bloginfo('stylesheet_directory');?>/js/menu.js' ></script> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.kwicks.js"></script>
If I do this in functions.php, the scripts load but don’t work:
function load_my_scripts() { wp_deregister_script( 'jquery' ); wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'); wp_enqueue_script('jquery'); wp_register_script('menu', get_stylesheet_uri().'/js/menu.js', array('jquery') ); wp_enqueue_script('menu'); wp_register_script('kwicks', get_stylesheet_uri().'/js/jquery.kwicks.js', array('jquery') ); wp_enqueue_script('kwicks'); wp_register_script('equalheights', get_stylesheet_uri().'/js/jquery.equalheights.js', array('jquery') ); wp_enqueue_script('equalheights'); } add_action('wp_enqueue_scripts', 'load_my_scripts');
Can someone see what I’m doing wrong?
Thanks.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Child theme scripts loading via wp_enqueue_scripts but not working’ is closed to new replies.