I use wordpress for my website. At the beginning of the using theme, slider was working but now I get these errors
TypeError: jQuery(...).nivoSlider is not a function
TypeError: jQuery(...).lightbox is not a function
TypeError: jQuery(...).prettyPhoto is not a function
TypeError: $ is not a function
My website address is : http://www.rgesc.com/
I have been searching solutions for this problem for a week, I tried to add jquery libs, above nivo.slider.js and tried to input this. I'm not good on wordpress and need help on this issue.
var j = jQuery.noConflict();
but nothing changes.
<script type='text/javascript' src='http://www.rgesc.com/wp-includes/js/jquery/jquery.js?ver=1.8'></script>
<script type='text/javascript' src='http://www.rgesc.com/wp-content/themes/theme1885/js/modernizr.js?ver=2.0.6'></script>
<script type='text/javascript' src='http://www.rgesc.com/wp-content/themes/theme1885/js/jquery.prettyPhoto.js?ver=3.1.3'></script>
<script type='text/javascript' src='http://www.rgesc.com/wp-content/themes/theme1885/js/jquery.nivo.slider.js?ver=2.5.2'></script>
<script type='text/javascript' src='http://www.rgesc.com/wp-content/themes/theme1885/js/jquery.loader.js?ver=1.0'></script>
<script type='text/javascript' src='http://www.rgesc.com/wp-content/themes/theme1885/js/superfish.js?ver=1.4.8'></script>
This lines in between head tags
<script type="text/javascript">
jQuery(window).load(function() {
// nivoslider init
jQuery('#slider').nivoSlider({
effect: 'boxRainReverse',
slices:15,
boxCols:8,
boxRows:8,
animSpeed:500,
pauseTime:5000,
directionNav:false,
directionNavHide:false,
controlNav:true,
captionOpacity:1 });
});
</script>
This line below other scripts
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
Additional photo galley is not working too. I just recognized that.
Here's an example of WordPress implementation using the Docs example, enqueuing the styles and scripts properly, and having all demo files inside the directory
/wp-content/themes/your-theme/nivo/
.The following code is inserted in the
functions.php
theme file. The shortcode is a helper to display the slider,[test-nivo]
(you'll have to pull the images from the post to make this dynamic). Note the use of the bundled WP jQuery as a dependency of our script, try not to use any external jQuery as they don't have thenoConflict
mode enabled.Main WP functions:
get_stylesheet_directory_uri
,wp_enqueue_script
andwp_enqueue_scripts
.Check the full list of bundled WP scripts here.
And our custom JS file,
start-nivo.js
:You are including jQuery three times:
the includes after the first will remove all the plugins bound to $ and jQuery, include jQuery once and you'll fix the issue.
I would recommend using only 1 jQuery version unless it is absolutely necessary.
Here is how you should use multiple jQuery versions on a website using
jQuery.noConflict()