<?php
/**
 * Template part for displaying About section
 *
 * @package Car Repair
 * @subpackage car_repair
 */
?>

<?php $automobile_hub_static_image = get_template_directory_uri() . '/assets/images/sliderimage.png'; ?>
<?php if( get_theme_mod( 'automobile_hub_product_show_hide',true) != '') { ?>
<section id="product" class="my-5">
  <div class="container">
    <div class="row mb-4">
      <div class="col-lg-8 col-md-6 align-self-center">
        <?php
        $car_repair_featured_car_section_short_title = get_theme_mod('car_repair_featured_car_section_short_title', '');
        if (!empty($car_repair_featured_car_section_short_title)) : ?>
          <h2 class="text-uppercase short-head"><?php echo esc_html($car_repair_featured_car_section_short_title); ?></h2>
        <?php endif; ?>
        
        <?php
        $car_repair_featured_car_section_tittle = get_theme_mod('car_repair_featured_car_section_tittle', '');
        if (!empty($car_repair_featured_car_section_tittle)) : ?>
          <h3 class="text-uppercase"><?php echo esc_html($car_repair_featured_car_section_tittle); ?></h3>
        <?php endif; ?>
      </div>
      <div class="col-lg-4 col-md-6 align-self-center">
        <div class="car-button text-center text-md-end my-3 my-md-0">
          <?php
          $car_repair_featured_car_button_text = get_theme_mod('car_repair_featured_car_button_text', '');
          $car_repair_featured_car_button_link = get_theme_mod('car_repair_featured_car_button_link', '');
          if (!empty($car_repair_featured_car_button_text) && !empty($car_repair_featured_car_button_link)) : ?>
            <a href="<?php echo esc_url($car_repair_featured_car_button_link); ?>" class="my-3">
              <i class="fas fa-angle-right me-4"></i><?php echo esc_html($car_repair_featured_car_button_text); ?>
            </a>
          <?php endif; ?>
        </div>
      </div>
    </div>
    <div class="row">
      <?php $car_repair_bestseller_product_pages = array();
            for ( $car_repair_count = 0; $car_repair_count <= 4; $car_repair_count++ ) {
              $mod = absint( get_theme_mod( 'car_repair_bestseller_product_page' ));
              if ( 'page-none-selected' != $mod ) {
                $car_repair_bestseller_product_pages[] = $mod;
              }
            }
            if( !empty($car_repair_bestseller_product_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $car_repair_bestseller_product_pages,
                'orderby' => 'post__in'
              );
              $query = new WP_Query( $args );
              if ( $query->have_posts() ) :
                $car_repair_count = 0;
                while ( $query->have_posts() ) : $query->the_post(); ?>
                  <?php the_content(); ?>
                <?php $car_repair_count++; endwhile; ?>
              <?php else : ?>
                  <div class="no-postfound"></div>
              <?php endif;
            endif;
            wp_reset_postdata();
          ?>
    </div>
  </div>
</section>
<?php }?>