I'm using Nivo Slider on my site from the basic example offered by the plugin. In the file header.php
of theme I put the scripts and <div>
with the images pointing to a theme directory. And in%% of slider initialization.
But how can I do this jQuery plugin integration by following WordPress standards and passing information dynamically? In the case of the slider, images.
footer.php
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><scripttype='text/javascript'src='<?phpechoget_template_directory_uri();?>/nivo/jquery.nivo.slider.pack.js'></script><linkrel='stylesheet'href='<?phpechoget_template_directory_uri();?>/nivo/nivo-slider.css'type='text/css'media='all'/><!--maiscódigo--></head><body<?phpbody_class();?>><divid="slider" class="nivoSlider">
<img src="<?php echo get_template_directory_uri(); ?>/nivo/nemo.jpg" alt="" />
<a href="http://example.com"><img src="<?php echo get_template_directory_uri(); ?>/nivo/toystory.jpg" alt="" title="#htmlcaption" /></a>
<img src="<?php echo get_template_directory_uri(); ?>/nivo/up.jpg" alt="" title="This is an example of a caption" />
<img src="<?php echo get_template_directory_uri(); ?>/nivo/walle.jpg" alt="" />
</div>
header.php
<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>
Question and answers inspired by Q & A jQuery (...) .nivoSlider is not a function in Wordpress .