WordPress Slider Auto Start

http://wordpress.org/support/topic/twenty-fourteen-slider-not-slide?replies=4#post-5046422

Here’s the code to be added to functions.php for the twentyfourteen template

function add_script_in_footer(){
?>
<script type="text/javascript" charset="utf-8">
    jQuery(document).ready(function(){
        var change_every = 5; // The number of seconds that the slider will auto-advance in
        var current = 1;
        function auto_advance(){
            if(current == -1) return false;
            jQuery('#featured-content .slider-next').eq(current % jQuery('#featured-content .slider-next').length).trigger('click', [true]);
            current++;
        };
        setInterval(function(){auto_advance()}, change_every * 1000);
    });
</script>
<?php
}
add_action('wp_footer', 'add_script_in_footer');

Leave a Reply