Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:43:07+00:00 2026-06-15T21:43:07+00:00

I’m using WordPress to create a homepage slideshow using Flexslider. I already have created

  • 0

I’m using WordPress to create a homepage slideshow using Flexslider. I already have created the options for the ability to type in the slideshow speed. How can I loop through those slideshow speeds for each individual slide?

$options[] = array( "name" => __('Banner 1 Speed','themetrust'),
                    "desc" => __('Enter speed in seconds for banner 1.','themetrust'),
                    "id" => "ttrust_home_banner_speed1",
                    "type" => "text");  
$options[] = array( "name" => __('Banner 2 Speed','themetrust'),
                    "desc" => __('Enter speed in seconds for banner 2.','themetrust'),
                    "id" => "ttrust_home_banner_speed2",
                    "type" => "text");


<?php $slideshow_delay = of_get_option('ttrust_slideshow_delay'); ?>
<?php $autoPlay = ($slideshow_delay != "0") ? 1 : 0; ?>
<?php $slideshow_effect = of_get_option('ttrust_slideshow_effect'); ?>

<script type="text/javascript">
//<![CDATA[

jQuery(window).load(function() {            
    jQuery('.flexslider').flexslider({
        slideshowSpeed: <?php echo $slideshow_delay . '000'; ?>,  
        directionNav: true,
        slideshow: <?php echo $autoPlay; ?>,                                
        animation: '<?php echo $slideshow_effect; ?>',
        animationLoop: true
    });  
});

//]]>
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:43:08+00:00Added an answer on June 15, 2026 at 9:43 pm

    I’m pretty sure that this is not a feature supported from FlexSlider, so here’s a way to get-around this:

    <?php $speed1 = intval( of_get_option( 'ttrust_home_banner_speed1' ) );
    $speed2 = ( of_get_option( 'ttrust_home_banner_speed2' ) );
    $speed1 = $speed1 ? $speed1 * 1000 : 6000; // Default duration of 6 seconds
    $speed2 = $speed2 ? $speed2 * 1000 : 6000; // Default duration of 6 seconds
    
    $slideshow_effect = of_get_option('ttrust_slideshow_effect'); ?>
    
    <script type="text/javascript">
    //<![CDATA[
    
    jQuery(window).load(function() {
        var delays = [ <?php echo $speed1; ?>, <?php echo $speed2; ?> ],
            _curr_index = 0,
            _delay = false, 
            _aa_timeout = null,
            _auto_advancing = false;
    
        jQuery('.flexslider').flexslider({
            slideshowSpeed: 0,
            directionNav: true,
            slideshow: false,
            animation: '<?php echo $slideshow_effect; ?>',
            animationLoop: true,
            after: function( slider ){
                // If we weren't advancing to the next slide from the auto_advance_slide() function(from user controls for instance), we need to fix some things
                if ( ! _auto_advancing ) {
                    clearTimeout( _aa_timeout ); // Clear the auto advance timeout
                    _curr_index = slider.currentSlide; // Fix the current index
                };
                // Set-up the next timer for auto advancing
                auto_advance_slide();
            }
        });
    
        function auto_advance_slide() {
            if ( typeof( delays[ _curr_index ] ) != 'undefined' ) {
                _delay = delays[ _curr_index ];
            } else {
                _delay = delays[ 0 ];
                _curr_index = 0;
            };
    
            // Set time out to switch to next slide
            _aa_timeout = setTimeout( function(){
                _auto_advancing = true;
                // Switch to next slide.
                jQuery('.flexslider').flexslider('next');
    
                _auto_advancing = false;
            }, _delay );
    
            // Increase the current index. 
            _curr_index ++;
        }
    
        auto_advance_slide();
    });
    
    //]]>
    </script>
    

    Basically you first get the duration for each slide(you can add more variables and options later) and check to make sure it has a proper value(use intval() to convert the value to an integer and then if it’s not false or 0, multiply it by a 1000 to get miliseconds value).

    In your JavaScript, you create a couple of variables.

    1. delays – this is an array containing the delays for all slides.
    2. _curr_index – this holds the current slide(and delays) index.
    3. _delay – we use this variable later, but we set it up here
    4. _aa_timeout – this variable will hold the reference to a timeout we’ll use later on
    5. _auto_advancing – this will be a flag variable, marking whether we’re advancing via our function, or the user used the FlexSlider navigation.

    When you set-up FlexSlider, you set no slideshow, since we’re going to advance the slides from our script. You also add a callback function for the after “event” of Flexslider – it executes after each slide’s animation completes. There we set-up the time out that will advance the slider to the next slide and check if the user has used the slider controls, or we’ve advanced to the next slide from our own script.

    Then we define the auto_advance_slide() function which actually sets-up the time out for advancing to the next slide.


    PP: I haven’t tested the function, some please test it and tell me if it’s not working(and preferrably what you see in FireBug, or Chrome’s developer console).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.