I have created a theme options page allowing the user to enter a number for setting the flex slider speed. The user will enter a number in miliseconds to define the specific speed they want.
For my flex slider I am using the following javascript to initialize the flex slider:
// Initialize Slider
function agencyclix_slider_initialize() { ?>
<script type="text/javascript" charset="utf-8">
jQuery(window).load(function() {
jQuery('.flexslider').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 283,
itemMargin: 0,
minItems: 1,
maxItems: 4,
move: 1,
touch: true,
pauseOnHover: true,
slideshowSpeed: 2500
});
});
</script>
How would I use the_field for the user input to control the speed?
Solved it with this: slideshowSpeed: [ “<?php the_field(‘set_carousel_speed’, ‘option’); ?>”]
The complete code:
// Initialize Slider
function agencyclix_slider_initialize() { ?>
<script type="text/javascript" charset="utf-8">
jQuery(window).load(function() {
jQuery('.flexslider').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 283,
itemMargin: 0,
minItems: 1,
maxItems: 4,
move: 1,
touch: true,
pauseOnHover: true,
slideshowSpeed: [ "<?php the_field('set_carousel_speed', 'option'); ?>"]
});
});
</script>