<?php
/**
 * section-slider.php
 *
 * @author    Denis Franchi
 * @package   Willer
 */

?>

<div id="carouselExampleIndicators" class="carousel slide willer-section-slider" data-ride="carousel">
  <div class="carousel-inner">
  <?php
	    $willer_category = esc_attr(get_theme_mod('willer_category_slider' ));
	    if( is_array($willer_category) ) {
	      $willer_category = implode(",", $willer_category);
	    }
	    if( !empty($willer_category) ) {
	      $willer_cat = $willer_category;
	    } else {
	      $willer_cat = 0;
	    }
			$willer_slider_count = 0;
			$willer_args = array(
				'cat' => $willer_category ,
				'showposts' => $willer_slider_count );
				$willer_slider_zoom_query = new WP_Query($willer_args);
				if( $willer_slider_zoom_query->have_posts() ) :
					while ( $willer_slider_zoom_query->have_posts() ) : $willer_slider_zoom_query->the_post();
					$willer_image_attributes =  wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'willer_big');?>
    	<!--Slider-->
        <div class="carousel-item item <?php if($willer_slider_count == 0){ echo 'active'; } ?>">
						<?php $willer_slider_count ++; ?>
						<img src="<?php if ( $willer_image_attributes[0] ) :
							echo esc_url($willer_image_attributes[0]);
						else: echo esc_url(get_template_directory_uri()).'/images/willer-default.jpg'; endif; ?>" alt="<?php the_title();?>">
						<div class="carousel-caption willer_caption">
							<h1><?php the_title();?></h1>
							<div class="divide-text"></div>
							  <?php the_excerpt();?>
							<button class="btn btn-1 btn-border-willer btn-1c"><a href="<?php the_permalink();?>"><?php esc_html_e( 'Learn More', 'willer' ); ?></a></button>
						</div>
					</div>
				<?php endwhile;
			endif;
			wp_reset_query(); // End Query Slider Zoom ?>
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only"><?php _e('Previous','willer')?></span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only"><?php _e('Next','willer')?></span>
  </a>
</div>