<?php 
$latestpost_enable = get_theme_mod( 'vw_book_store_pro_radio_post_enable' );
if ( 'Disable' == $latestpost_enable ) {
  return;
}
/*Latest post*/
$img_bg = get_theme_mod('vw_book_store_pro_our_latest_post_image_bg');
if( get_theme_mod('vw_book_store_pro_latest_post_color') ) { 
  $about_backg = 'background-color:'.esc_attr(get_theme_mod('vw_book_store_pro_latest_post_color')).';';
}elseif( get_theme_mod('vw_book_store_pro_our_latest_post_bgimage') ){
  $about_backg = 'background-image:url(\''.esc_url(get_theme_mod('vw_book_store_pro_our_latest_post_bgimage')).'\')';
}else{
  $about_backg = '';   
}

if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
  $amp_class = 'col-lg-3 col-md-3 col-sm-6 col-12 mb-3';
  $amp_row = 'row';
}
else{
  $amp_class = '';
  $amp_row = '';
}
?>
<section id="latest_post" style="<?php echo esc_html($about_backg); ?>" class="wow zoomIn delay-3000 animated <?php echo esc_attr($img_bg); ?>" data-wow-duration="2s">
  <div class="innerbox">
    <div class="container">  
    <?php if(get_theme_mod('vw_book_store_pro_latestpost_title',true) != '' || get_theme_mod('vw_book_store_pro_latestpost_btn',true) != ''){?>
      <div class="section-title d-inline-block w-100">

        <?php if( get_theme_mod('vw_book_store_pro_latestpost_title',true) != ''){ ?>
          <h3 class="float-left align-self-end"><?php echo esc_html(get_theme_mod('vw_book_store_pro_latestpost_title')); ?></h3>
        <?php } ?>

        <?php if( get_theme_mod('vw_book_store_pro_latestpost_btn',true) != ''){ ?>
          <a class="theme_green_button float-right" href="<?php echo esc_url(get_theme_mod('vw_book_store_pro_latestpost_btn_link')); ?>"><?php echo esc_html(get_theme_mod('vw_book_store_pro_latestpost_btn')); ?><i class="<?php echo esc_html(get_theme_mod('vw_book_store_pro_latestpost_btn_icon')); ?>"></i></a>
        <?php } ?>
      </div>
    <?php } ?>
    <div class="owl-carousel <?php echo esc_attr($amp_row); ?>">
      <?php
        $args = array(
          'post_type' => 'post',
          'category_name' => get_theme_mod('vw_book_store_pro_latestblogpost_setting')
        );
        $new = new WP_Query($args); 
        $loop_index = 0; $i=1;
           while ( $new->have_posts() ){
            $new->the_post();  ?>
            <div class="<?php if($i == 1){ echo 'active';}?> <?php echo esc_attr($amp_class); ?>">
              <div class="newsinner">
                <div class="collectionbox">
                  <?php if (has_post_thumbnail()){ ?>
                    <?php the_post_thumbnail(); ?>                    
                  <div class="collectionbox-content">
                      <ul class="collectionicon">
                        <li><a href="<?php the_permalink(); ?>"><i class="fa fa-link"></i></a></li>
                        <li><a href="#"><i class="far fa-comments mr-2"></i><?php comments_number( __('0','vw-book-store-pro'), __('0','vw-book-store-pro'), __('%','vw-book-store-pro') ); ?></a></li>
                      </ul>
                  </div>
                  <div class="post_date"><?php the_time(get_option('date_format')); ?></div>
                  <?php } ?>
                </div>
                <div class="collectionbox-text">                  
                  <h3><div class="divider"></div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                  <p><?php $excerpt = get_the_excerpt(); echo esc_html(vw_book_store_pro_string_limit_words($excerpt,15)); ?></p>
                  <?php if ( get_theme_mod('vw_book_store_pro_latestpost_readmore',true) != "" ) { ?>
                    <div class="readmore">
                      <a class="theme_white_button d-inline-block" href="<?php the_permalink(); ?>"><?php echo esc_html(get_theme_mod('vw_book_store_pro_latestpost_readmore'));?></a>
                    </div>
                  <?php }?> 
                </div>
              </div>
            </div>
            <?php $i++; }
           wp_reset_query(); ?>
        </div>
      </div>
    </div>
  </div>
</section>