Trouble with wp_enqueue_script
-
Hello, I am trying to add the jquery cycle plugin (http://jquery.malsup.com/cycle/) to my wordpress site.
I downloaded the jquery.cycle.all.js file and put in in my child theme (lets call it TestChild) in the directory like so TestChild/assets/scripts/jquery.cycle.all.jsIn my functions.php of my child theme I then proceeded to insert this:
//Add Cycle add_action ('wp_enqueue_script', 'theme_add_cycle_slide' ); function theme_add_cycle_slide (){ wp_enqueue_script('jquery'); wp_enqueue_script('cycleall', get_stylesheet_directory_uri() . '/assets/scripts/jquery.cycle.all.js'); }In my body I have the following:
<div id="slideshow"> <div style="width:250px; height:150px; background:red;"></div> <div style="width:250px; height:150px; background:blue;"></div> <div style="width:250px; height:150px; background:green;"></div> <div style="width:250px; height:150px; background:yellow;"> </div> <div id="prev" style="float:left;">PREV</div> <div id="next" style="float:right;">NEXT</div>In my footer, just before the </body> tag I have the javascript function:
<!-- Slideshow --> <script language="javascript"> jQuery(document).ready(function($) { $('#slideshow').cycle({ fx: 'fade', pause: 1 }); }); </script>When I load the site, I get a console error:
Uncaught TypeError: $(…).cycle is not a functionWhen I load the source, the script is not present. I don’t understand what I am doing incorrectly. I would appreciate any help as this has been causing me hours of frustration.
[moderated to add “code” blocks]
The topic ‘Trouble with wp_enqueue_script’ is closed to new replies.