An easy one for anybody with PHP knowledge...

Thank you so much for your attention! I am attaching a bit of PHP that came with a Wordpress theme that I purchased recently. It is a slider that features the featured images of the most recent posts. All I need it to do is to get the slider to play automatically. It seems to be built to be handled manually. I would like to have the option of watching the slider play all the slides, however have the “next” and “previous” buttons ever present (as they already are) to allow the viewer to speed through the slideshow manually. Essentially, I want the slider to start playing all the slides upon download at perhaps 5 seconds a slide. Your assistance is SOOOOOO appreciated. :slight_smile:

[php]class Report_Widget_Slider extends WP_Widget {

public function __construct() {

	parent::__construct(
 		'report_slider',
		__( 'Slider', 'eqfw' ),
		array(
			'description' => __( 'Simple slider', 'eqfw' ),
		)
	);

}

public function widget( $args, $instance ) {

	echo $args['before_widget'];

	echo get_widget_title( $args, $instance );

	if ( $instance['ids'] ) {
		$query_string = array( 'post__in' => explode( ',', str_replace( ' ', '', $instance['ids'] ) ) );
	} else {
		$query_string = 'posts_per_page=4';
		$query_string .= ( $instance['additional_parameters'] ) ? '&' . $instance['additional_parameters'] : '';
	}

	$query = new WP_Query( $query_string );

	$i = 0;

	?>

	<a href="#" class="slider_pagination is-previous"><i class="icon-angle-left"></i></a>
	<a href="#" class="slider_pagination is-next"><i class="icon-angle-right"></i></a>

	<ul class="slider_slides">

		<?php while ( $query->have_posts() ): $query->the_post(); $i++; ?>

			<li class="<?php if ($i == 1) echo 'is-active'; ?>">

				<article class="article <?php if ( isset( $instance['style'] ) ) echo 'is-' . $instance['style']; ?>">

					<?php $video_slider = get_post_meta( get_the_ID(), 'eqfw_video_slider', true ); ?>
					<?php if ( $video_slider ): ?>

						<!-- Video -->
						<div class="article_video">
							<video preload="metadata">
								<?php echo $video_slider; ?>
							</video>
						</div>

					<?php else: ?>

						<!-- Thumbnail -->
						<?php if ( has_post_thumbnail() ): ?>
							<div class="article_thumbnail">
								<?php
									if ( isset( $instance['style'] ) && $instance['style'] == 'centered' ) {
										the_post_thumbnail( 'slider-wide' );
									} else {
										the_post_thumbnail( 'slider' );
									}
								?>
							</div>
						<?php endif; ?>

					<?php endif; ?>

					<!-- Link -->
					<a href="<?php the_permalink(); ?>" class="article_link"></a>

					<!-- Image overlay -->
					<div class="article_overlay">

						<!-- Title -->
						<h3 class="article_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

						<!-- Excerpt -->
						<div class="article_description">

							<!-- Categories -->
							<?php if ( isset($instance['show_categories']) ): ?>
								<div class="article_inline-categories">
									<?php foreach ( get_the_category() as $category ): ?>
										<a href="<?php echo get_category_link( $category->term_id ); ?>">
											<?php echo $category->cat_name; ?>
										</a>
									<?php endforeach; ?>
								</div>
							<?php endif; ?>

							<?php the_excerpt(); ?>

						</div>

					</div>


				</article>

			</li>

		<?php endwhile; ?>

	</ul>

	<?php

	wp_reset_postdata();

	echo $args['after_widget'];

}


public function form( $instance ) {

	$instance = shortcode_atts( array(
		'title' => '',
		'show_categories' => '',
		'ids' => '',
		'additional_parameters' => '',
		'style' => 'centered'
	), $instance );

	?>
		<p>
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'eqfw' ); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
		</p>
		<p>
			<span><?php _e( 'Style', 'eqfw' ); ?></span><br>
			<label for="<?php echo $this->get_field_id( 'style' ); ?>[centered]">
				<input type="radio" id="<?php echo $this->get_field_id( 'style' ); ?>[centered]" name="<?php echo $this->get_field_name( 'style' ); ?>" value="centered" <?php checked( $instance['style'], 'centered' ); ?> />
				Description in the center
			</label>
			<label for="<?php echo $this->get_field_id( 'style' ); ?>[bottom]">
				<input type="radio" id="<?php echo $this->get_field_id( 'style' ); ?>[bottom]" name="<?php echo $this->get_field_name( 'style' ); ?>" value="bottom" <?php checked( $instance['style'], 'bottom' ); ?> />
				Description at the bottom
			</label>
		</p>
		<p>
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_categories'] ) ?> id="<?php echo $this->get_field_id( 'show_categories' ); ?>" name="<?php echo $this->get_field_name('show_categories'); ?>" />
			<label for="<?php echo $this->get_field_id( 'show_categories' ); ?>"><?php _e( 'Show categories', 'eqfw' ); ?></label>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id( 'ids' ); ?>"><?php _e( 'Post IDs (comma separated):', 'eqfw' ); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id( 'ids' ); ?>" name="<?php echo $this->get_field_name( 'ids' ); ?>" type="text" value="<?php echo esc_attr( str_replace( ' ', '', $instance['ids'] ) ); ?>" />
			<small>
				Enter comma-separated IDs of posts.<br>
				If not specified, 4 latest posts are displayed.
			</small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id( 'additional_parameters' ); ?>"><?php _e( 'Additional WP_Query parameters:', 'eqfw' ); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id( 'additional_parameters' ); ?>" name="<?php echo $this->get_field_name( 'additional_parameters' ); ?>" type="text" value="<?php echo esc_attr( $instance['additional_parameters'] ); ?>" />
			<small>
				Take a look at <a href="http://codex.wordpress.org/Class_Reference/WP_Query">WP_Query documentation</a> for possible parameters.
				Example: <code>posts_per_page=4</code> (shows last 4 posts)
			</small>
		</p>[/php]

Well, this is not an easy one. At least not for me. First, since it is a Wordpress template, it is set up to use whatever the back-end system lets you set for options. If it is not set up for auto-scrolling with options for timing or speed of switching next/previous, etc… it is very hard to decode someone else’s routines.

Now, a simple way around it might be to just create a Javascript timer and manually press the Next/Previous buttons that way. A simple timer would go off every second or whatever and press the button for you. It would require just adding a small routine to the page. Just an idea.

But, another thought is that since you purchased the template, they should assist you in this “easy one”…

Not sure if this helps or not… Good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service