Play bxSlider on element hover

admin

Administrator
Staff member
I have a wordpress loop loading multiple bxsliders onto one page, i want these sliders to start individually and stop individually on hover of the parent element. I can't figure out how to do so.

Obviously i will need to use a

Code:
$('.item').each

But im not sure how to stop and start the bxslider on the hover. Does anyone have a solution?

Here is some sample code:

Code:
if ( have_posts() ) while ( have_posts() ) : the_post(); 
            ?>
                <div class="item">
                            <div class="thumbnail clearfix">
                                <ul>
                                    <li><?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
                                        <h1 title="<?php the_title(); ?>" >
                                            <a href="<?php the_field('website_url'); ?>"><?php the_post_thumbnail(); ?></a>
                                        </h1>
                                        <?php endif; ?>
                                    </li>
                                    <li>
                                        <div>
                                        <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif; ?>
                                        </div>
                                    </li>
                                    <li>
                                        <div>
                                        <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'third-image'); endif; ?>
                                        </div>
                                    </li>
                                </ul>
                             </div>
                     </div> 
<?php endwhile; ?>

So you can see there im, pulling 3 thumbnails out... in the slider and this is within a post so there could be anywhere between 1 and 10 on the page.

My first idea was to initiate the bxslider on hover....

Code:
    $('.item').each(function(){
    $(this).hover({
        $(this).find('.thumbnail ul').bxSlider({
            auto: true
        });
    });
});

But this doesn't work. How i want it to, i want it to build the slider on each one... then when the user hovers make the slider start... and on mouse off stop.

Thanks in advanced.