<?php
/**
 * Banner Slider Section
 *
 * @package Excel_Business
 */

$ed_slider  = get_theme_mod( 'ed_slider', true );
$ed_caption = get_theme_mod( 'slider_caption', true );    
$slider_cat = get_theme_mod( 'slider_cat' );
$readmore   = get_theme_mod( 'slider_read_more', __( 'Read More', 'excel-business' ) );

if( $ed_slider && $slider_cat && is_front_page() ){

    $args = array(
        'post_type'           => 'post',
        'post_status'         => 'publish',
        'posts_per_page'      => -1,       
        'cat'                 => $slider_cat,
        'ignore_sticky_posts' => true
    );
    
    $qry = new WP_Query( $args );
    
    if( $qry->have_posts() ){ ?>
        <div class="banner">
    		<div class="owl-carousel owl-theme" id="banner-slider">
    			<?php
                while( $qry->have_posts() ){
                    $qry->the_post(); 
                    if( has_post_thumbnail() ){
                    ?>
                    <div class="item">
        				<?php the_post_thumbnail( 'excel-business-slider' ); ?>
        				<?php if( $ed_caption ){ ?>
                            <div class="banner-text">
            					<div class="container">
            						<div class="table">
            							<div class="table-row">
            								<div class="table-cell">
            									<div class="text-holder">
                                                <?php
                                                    the_title( '<h2 class="title">', '</h2>' );                                                    
                                                    the_excerpt();                                                    
                                                    if( $readmore ) echo '<a href="' . esc_url( get_the_permalink() ) . '" class="btn-view">' . esc_html( $readmore ) . '</a>';
                                                ?>
            									</div>
            								</div>
            							</div>
            						</div>
            					</div>
            				</div>
                        <?php } ?>
        			</div>        			
                    <?php
                    }
                }
                wp_reset_postdata(); 
                ?>
    		</div>
    	</div>
     <?php
    }
}