<?php 
$latestpost_enable = get_theme_mod( 'advance_education_pro_radio_post_enable' );
if ( 'Disable' == $latestpost_enable ) {
  return;
}
/*Latest post*/
if( get_theme_mod('advance_education_pro_latest_news_bgcolor') ) { 
  $about_backg = 'background-color:'.esc_attr(get_theme_mod('advance_education_pro_latest_news_bgcolor')).';';
}elseif( get_theme_mod('advance_education_pro_latest_news_bgimage') ){
  $about_backg = 'background-image:url(\''.esc_url(get_theme_mod('advance_education_pro_latest_news_bgimage')).'\')';
}else{
  $about_backg = '';   
}
$att_style="";
  $image_att = get_theme_mod( 'advance_education_pro_latest_news_bgimage_attachment',true );
  if ( 'Scroll' == $image_att ) {
    $att_style="section_bg_scroll";
  }else{
    $att_style="section_bg_fixed";
  }  
?>
<section id="latest_news" style="<?php echo esc_html($about_backg); ?>" class="<?php echo esc_attr($att_style)?>">
  <div class="innerbox">
    <div class="container">  
    <div class="section-heading">
      <?php if(get_theme_mod('advance_education_pro_latest_news_title') != ''){?>
          <h3> 
            <?php if(get_theme_mod('advance_education_pro_title_icon')){
              ?> <i class="<?php echo esc_html(get_theme_mod('advance_education_pro_title_icon')) ?>"></i><?php
            }?>
            <?php echo esc_html(get_theme_mod('advance_education_pro_latest_news_title')); ?></h3>
      <?php } ?>
      <?php if(get_theme_mod('advance_education_pro_latest_news_subtitle') != ''){?>
          <p><?php echo esc_html(get_theme_mod('advance_education_pro_latest_news_subtitle')); ?></p>
      <?php } ?>
    </div>
    <div class="owl-carousel">
      <?php
        $args = array(
          'post_type' => 'post',
          'category_name' => get_theme_mod('advance_education_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';}?>"> 
              <div class="box">
                <div class="image-box media">
                  <?php if (has_post_thumbnail()){ ?>
                    <?php the_post_thumbnail(); ?>
                  <?php } ?>
                  <div class="overlay">
                    <div class="title-section">
                      <div class="title-div">
                        <p class="title"><?php the_title(); ?></p>
                        <span class="author-name"><?php the_author(); ?></span>
                        <span class="entry-date price"><?php the_time(get_option('date_format')); ?></span>
                      </div>
                    </div>
                  </div>
                  <div class="latest-news-hover">
                    <div class="latest-news-content">
                      <h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                      <span class="author-name"><?php the_author(); ?></span>
                      <span class="entry-date"><?php the_time(get_option('date_format')); ?></span>
                      <p class="subtitle"><?php $excerpt = get_the_excerpt(); echo esc_html(advance_education_pro_string_limit_words($excerpt,25)); ?></p>
                      <?php if(get_theme_mod('advance_education_pro_latest_news_read_more') != ''){?>
                        <div class="apply-now"><a href="<?php the_permalink(); ?>" class="apply" ><?php echo esc_html(get_theme_mod('advance_education_pro_latest_news_read_more')); ?></a></div>
                      <?php } ?>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <?php $i++; }
           wp_reset_query(); ?>
        </div>
        <div class="latest-btn">
          <?php if(get_theme_mod('advance_education_pro_latest_news_view_all_text') != '') {?>
            <a class="latest-btn" href="<?php echo esc_html(get_theme_mod('advance_education_pro_latest_news_view_all_link')); ?>"><?php echo esc_html(get_theme_mod('advance_education_pro_latest_news_view_all_text'))?></a>
          <?php } ?>
        </div>
      </div>
    </div>
  </div>
</section>