<?php
/**
 * Banner Section
 * 
 * @package prime_magazine
 */
$prime_magazine_slide            = get_theme_mod( 'prime_magazine_slider_setting',false );
$prime_magazine_slide_button     = get_theme_mod( 'prime_magazine_slider_button_setting',false );
$prime_magazine_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' =>  get_theme_mod('prime_magazine_blog_slide_category'),
  'posts_per_page' => 3,
);

$prime_magazine_live_update_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' =>  get_theme_mod('prime_magazine_live_update_category'),
  'posts_per_page' => 6,
);

?>
<?php if ( $prime_magazine_slide ){?>
<div class="banner">
  <div class="owl-carousel">
    <?php $prime_magazine_arr_posts = new WP_Query( $prime_magazine_args );
    if ( $prime_magazine_arr_posts->have_posts() ) :
      while ( $prime_magazine_arr_posts->have_posts() ) :
        $prime_magazine_arr_posts->the_post();
        ?>
        <div class="banner_inner_box">
          <?php if(has_post_thumbnail()){ ?>
            <img src="<?php the_post_thumbnail_url('full'); ?>"/>

          <?php }else { ?>

            <div class="banner_background"></div> 

          <?php } ?>

          <div class="banner_box">
            <div class="banner_content wow zoomIn" data-wow-duration="2s">
              <h3 class="my-3"><?php the_title(); ?></h3>
              <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 30 ); ?></p>
              <?php if ( $prime_magazine_slide_button ){?>
                <p class="btn-green mt-4">
                  <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('Go To Live News','prime-magazine'); ?></a>
                </p>
              <?php } ?>
            </div>
            <div class="live_update">
              <h4><?php esc_html_e('Live Update','prime-magazine'); ?></h4>
              <?php $prime_magazine_live_update_posts = new WP_Query( $prime_magazine_live_update_args );
                if ( $prime_magazine_live_update_posts->have_posts() ) :
                while ( $prime_magazine_live_update_posts->have_posts() ) :
                $prime_magazine_live_update_posts->the_post();
                ?>
                  <span><?php echo esc_html( get_the_time() ); ?></span>
                  <h4 class="my-3"><a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php the_title(); ?></a></h4>
              <?php
              endwhile;
              wp_reset_postdata();
              endif; ?>
            </div>
          </div>
        </div>
      <?php
    endwhile;
    wp_reset_postdata();
    endif; ?>
  </div>
</div>
<?php } ?>