<?php 
/**
 * Template part for displaying Trending Post Section
 *
 * @package News Press Release
 */
$news_press_release_trending = get_theme_mod('news_press_release_trending_setting', false);
$news_press_release_trending_post_slider_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' => get_theme_mod('news_press_release_trending_post_slider_args'),
  'posts_per_page' => 6,
);

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

$news_press_release_trending_post_title = get_theme_mod('news_press_release_trending_post_title');

?>
<?php if ($news_press_release_trending) { ?>
<div class="trending_post">
  <h2><span><?php echo esc_html($news_press_release_trending_post_title); ?><span></h2>
  <div class="row pb-5">
    <div class="col-lg-6 col-md-6">
      <div class="owl-carousel">
        <?php
        $news_press_release_trending_post_slider_posts = new WP_Query($news_press_release_trending_post_slider_args);
        if ($news_press_release_trending_post_slider_posts->have_posts()) :
          while ($news_press_release_trending_post_slider_posts->have_posts()) :
            $news_press_release_trending_post_slider_posts->the_post();
        ?>
            <div class="trending_post_inner">
              <?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/trend-default.png" class="banner_background" />
              <?php } ?>
              <div class="trending_post_inner_content">
                <span class="front-post-category">
                  <?php the_category(', '); ?>
                </span>
                <h3><a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php the_title(); ?></a></h3>
                <p><?php echo wp_trim_words(get_the_content(), 20); ?></p>
                <div class="entry-meta">
                  <?php news_press_release_posted_on(); ?>
                </div>
              </div>
            </div>
        <?php
          endwhile;
          wp_reset_postdata();
        endif;
        ?>
      </div>
    </div>
    <div class="col-lg-6 col-md-6">
      <div class="trending_category_box">
        <?php
        $news_press_release_trending_category_posts = new WP_Query($news_press_release_trending_category_args);
        if ($news_press_release_trending_category_posts->have_posts()) :
          while ($news_press_release_trending_category_posts->have_posts()) :
            $news_press_release_trending_category_posts->the_post();
        ?>
            <div class="trending_category_inner">
              <div class="row">
                <div class="col-lg-4 col-md-4 col-5">
                  <?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/trend-default.png" class="banner_background" />
                  <?php } ?>
                </div>
                <div class="col-lg-8 col-md-8 col-7">
                  <div class="trending_category_content">
                    <?php the_category(); ?>
                    <h4><a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php the_title(); ?></a></h4>
                  </div>
                </div>
              </div>
            </div>
        <?php
          endwhile;
          wp_reset_postdata();
        endif;
        ?>
      </div>
    </div>
  </div>
</div>
<?php } ?>
