<?php
/**
 * Banner Section
 * 
 * @package content_marketing
 */

$content_marketing_slider = get_theme_mod( 'content_marketing_slider_setting', false );
$content_marketing_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' => get_theme_mod( 'content_marketing_blog_slide_category' ),
  'posts_per_page' => 3,
);

?>

<?php if ( $content_marketing_slider ) : ?>
<div class="slider-back">
  <div class="banner-main">
    <div class="test">
      <div class="owl-carousel">
        <?php 
        $content_marketing_arr_posts = new WP_Query( $content_marketing_args );
        if ( $content_marketing_arr_posts->have_posts() ) :
          while ( $content_marketing_arr_posts->have_posts() ) :
            $content_marketing_arr_posts->the_post();
        ?>
        <div class="banner_inner_box">
          <div class="container">
            <div class="row">
              <div class="col-lg-6 col-md-12 col-12 align-self-center">
                <div class="banner_box">
                  <h3 class="my-3"><?php the_title(); ?></h3>
                  <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 20 ); ?></p>
                  <p class="btn-green mt-4">
                    <a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>">
                      <?php esc_html_e( 'Subscribe Now', 'content-marketing' ); ?>
                    </a>
                  </p>
                </div>
              </div>
              <div class="col-lg-6 col-md-12 col-12 align-self-center position-relative p-0">
                <div class="slider-img-color">
                  <div class="banner_inner_box_img wow zoomIn" data-wow-duration="2s">
                    <?php if ( has_post_thumbnail() ) : ?>
                      <?php the_post_thumbnail(); ?>
                    <?php else : ?>
                      <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>" alt="Default Image">
                    <?php endif; ?>
                  </div>
                </div>
                <span class="slider-dot"></span>
              </div>
            </div>
          </div>
        </div>
        <?php endwhile; ?>
        <?php wp_reset_postdata(); ?>
        <?php endif; ?>
      </div>
    </div>
  </div>
</div>
<?php endif; ?>