<?php
/**
 * Banner Section
 * 
 * @package news_press_release
 */
$news_press_release_slide            = get_theme_mod( 'news_press_release_slider_setting', false );
$news_press_release_slide_button     = get_theme_mod( 'news_press_release_slider_button_setting', true );
$args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' => get_theme_mod('news_press_release_blog_slide_category'),
  'posts_per_page' => 3,
);

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

?>
<?php if ($news_press_release_slide) { ?>
  <div class="banner">
    <div class="owl-carousel">
      <?php $news_press_release_arr_posts = new WP_Query($args);
      if ($news_press_release_arr_posts->have_posts()) :
        while ($news_press_release_arr_posts->have_posts()) :
          $news_press_release_arr_posts->the_post();
          ?>
          <div class="banner_inner_box">
            <?php if (has_post_thumbnail()) { ?>
              <img src="<?php the_post_thumbnail_url('full'); ?>" />
            <?php } else { ?>
              <img src="<?php echo esc_url( get_template_directory_uri() . '/images/slider-deafult.png' ); ?>" />

            <?php } ?>

            <div class="banner_box">
              <div class="banner_content wow bounceInDown" 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 ($news_press_release_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', 'news-press-release'); ?></a>
                  </p>
                <?php } ?>
              </div>
              <div class="live_update">
                <h4><?php esc_html_e('Live Update', 'news-press-release'); ?></h4>
                <?php $news_press_release_live_update_posts = new WP_Query($news_press_release_live_update_args);
                if ($news_press_release_live_update_posts->have_posts()) :
                  while ($news_press_release_live_update_posts->have_posts()) :
                    $news_press_release_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 } ?>
