<?php 
$expert_ac_repair_slider = get_theme_mod('expert_ac_repair_slider_setting', true);

if ($expert_ac_repair_slider == '1') :
?>

<section id="slider">
  <div id="owl-carousel" class="owl-carousel">
      <?php
      $expert_ac_repair_slide_pages = array();
      for ($expert_ac_repair_count = 1; $expert_ac_repair_count <= 3; $expert_ac_repair_count++) {
          $expert_ac_repair_mod = intval(get_theme_mod('expert_ac_repair_slider_page' . $expert_ac_repair_count));
          if ('page-none-selected' !== $expert_ac_repair_mod && $expert_ac_repair_mod > 0) {
              $expert_ac_repair_slide_pages[] = $expert_ac_repair_mod;
          }
      }

      if (!empty($expert_ac_repair_slide_pages)) :
          $expert_ac_repair_args = array(
              'post_type' => 'page',
              'post__in' => $expert_ac_repair_slide_pages,
              'orderby' => 'post__in'
          );
          $expert_ac_repair_query = new WP_Query($expert_ac_repair_args);
          if ($expert_ac_repair_query->have_posts()) :
              while ($expert_ac_repair_query->have_posts()) : $expert_ac_repair_query->the_post(); ?>
                  <div class="item">
                      <?php if (has_post_thumbnail()) { ?>
                          <img src="<?php echo esc_url(get_the_post_thumbnail_url(get_the_ID(), 'full')); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" />
                      <?php } else { ?>
                          <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/default-slider.png'); ?>" alt="Default Image" />
                      <?php } ?>

                      <div class="container">
                          <div class="carousel-caption">
                              <div class="inner_carousel wow fadeInUp" data-wow-delay="0.5s">
                                  <?php if (get_theme_mod('expert_ac_repair_slider_short_heading') != '') { ?>
                                      <p class="slidetop-text mb-3"><?php echo esc_html(get_theme_mod('expert_ac_repair_slider_short_heading', '24-Hours Emergency Service')); ?></p>
                                  <?php } ?>
                                  <h1 class="custom-title mb-3">
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                  </h1>
                                  <p class="mb-2 slider-content"><?php echo esc_html(wp_trim_words(get_the_content(), 35)); ?></p>
                                  <div class="more-btn mt-3">
                                      <?php 
                                      $expert_ac_repair_btn_text = get_theme_mod('expert_ac_repair_slider_btn_text', __('LEARN MORE', 'expert-ac-repair'));
                                      $expert_ac_repair_btn_link = get_theme_mod('expert_ac_repair_slider_btn_link');
                                      
                                      if ($expert_ac_repair_btn_text || $expert_ac_repair_btn_link) { ?>
                                          <a target="_blank" class="text-capitalize slider-btn1" href="<?php echo esc_url($expert_ac_repair_btn_link ? $expert_ac_repair_btn_link : get_permalink()); ?>">
                                              <?php echo esc_html($expert_ac_repair_btn_text); ?>
                                          </a>
                                      <?php } ?>
                                  </div>
                              </div>
                          </div>
                      </div>
                  </div>
              <?php endwhile;
              wp_reset_postdata(); ?>
          <?php else : ?>
              <div class="no-postfound"></div>
          <?php endif;
      endif; ?>
  </div>
</section>
<?php endif; ?>