<?php if ( get_theme_mod('auto_parts_supplier_blog_box_enable') ) : ?>

<?php $auto_parts_supplier_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' =>  get_theme_mod('auto_parts_supplier_blog_slide_category'),
  'posts_per_page' => get_theme_mod('auto_parts_supplier_blog_slide_number'),
); ?>

<div class="slider">
  <?php if ( get_theme_mod('auto_parts_supplier_slider_banner_image') ) : ?>
    <img class="inner-banner" src="<?php echo esc_url(get_theme_mod('auto_parts_supplier_slider_banner_image'));?>">
  <?php else: ?>
    <div class="slider-alternate">
      <img src="<?php echo get_stylesheet_directory_uri() . '/assets/images/slider.png'; ?>">
    </div>
  <?php endif; ?>

  <div class="slider-main-box">
    <div class="owl-carousel">
      <?php $auto_parts_supplier_arr_posts = new WP_Query( $auto_parts_supplier_args );
      if ( $auto_parts_supplier_arr_posts->have_posts() ) :
        while ( $auto_parts_supplier_arr_posts->have_posts() ) :
          $auto_parts_supplier_arr_posts->the_post();
          ?>
          <div class="blog_inner_box">
            <div class="container">
              <div class="row">
                <div class="col-lg-6 col-md-6 align-self-center">
                  <div class="blog_box wow zoomIn pt-3 pt-md-0">
                    <?php if ( get_theme_mod('auto_parts_supplier_slider_short_heading') ) : ?>
                      <h4 class="m-0"><?php echo esc_html(get_theme_mod('auto_parts_supplier_slider_short_heading'));?></h4>
                    <?php endif; ?>
                    <?php if ( get_theme_mod('auto_parts_supplier_title_unable_disable',true) ) : ?>
                      <h3 class="my-3"><?php the_title(); ?></a></h3>
                    <?php endif; ?>
                    <p class="mb-2"><?php echo wp_trim_words(get_the_content(), 20); ?></p>
                    <?php if ( get_theme_mod('auto_parts_supplier_button_unable_disable',true) ) : ?>
                      <p class="slider-button mt-4">
                        <a class="me-5" href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('Know More','auto-parts-supplier'); ?></a>
                      </p>
                    <?php endif; ?>
                  </div>
                </div>
                <div class="col-lg-6 col-md-6 slider-image align-self-center">
                  <?php
                    if ( has_post_thumbnail() ) :
                      the_post_thumbnail();
                    else:
                      ?>
                      <div class="slider-alternate">
                        <img src="<?php echo get_stylesheet_directory_uri() . '/assets/images/banner-main.png'; ?>">
                      </div>
                      <?php
                    endif;
                  ?>
                </div>
              </div>
            </div>
          </div>
        <?php
      endwhile;
      wp_reset_postdata();
      endif; ?>
    </div>
  </div>
</div>

<?php endif; ?>
