<section id="slider-section" class="slider-area home-slider">
  <!-- <div class="slideinning"></div> -->
  <!-- start of hero --> 
  <section class="hero-slider hero-style">
    <div class="mini_golfswiper-container">
      <div class="swiper-wrapper">

        <?php
          $has_slider = false;

          // Check if any slider is set
          for ( $i = 1; $i <= 5; $i++ ) {
              if ( get_theme_mod( 'slider' . $i ) ) {
                  $has_slider = true;
                  break;
              }
          }
        ?>

        <?php if ( $has_slider ) : ?>

          <?php for($p=1; $p<6; $p++) { ?>
          <?php if( get_theme_mod('slider'.$p,false)) { ?>
          <?php $querycolumns = new WP_query('page_id='.get_theme_mod('slider'.$p,true)); ?>
          <?php while( $querycolumns->have_posts() ) : $querycolumns->the_post(); 
            $image = wp_get_attachment_image_src(get_post_thumbnail_id() , true); ?>
          <?php 
            if(has_post_thumbnail()){
              $img = esc_url($image[0]);
            }
            if(empty($image)){
              $img = get_template_directory_uri().'/assets/images/bannerimg.png';
            }

          ?>
          <!-- <div class="container"> -->
          <div class="mini_golfswiper-slide">
              <div class="mini_golfslide-inner slide-bg-image">
                  <div class="sliderimg">
                      <img class="slide-mainimg slidershape1" src="<?php echo esc_url($img); ?>" alt="<?php the_title_attribute(); ?>">
                      <div class="slider-olay"></div>                
                      <div class="slidercontent">
                          <div class="sub-title"> 
                            <?php echo (get_theme_mod('slider_section_subheading', 'Est. 1923')); ?>
                          </div>         
                          <h2><?php the_title_attribute(); ?></h2>           
                          <div class="slide-text"> 
                            <?php the_excerpt(); ?>
                          </div>
                          <div class="slide-btns">
                              <a class="contactus" href="<?php echo esc_url(get_theme_mod('slider_btnlink2', '#')); ?>">
                                <?php echo esc_html(get_theme_mod('slider_btntext1', 'Learn More')); ?>
                              </a>
                              <a class="ReadMore" href="<?php echo esc_url(get_theme_mod('slider_btnlink1', '#')); ?>">
                                <?php echo esc_html(get_theme_mod('slider_btntext2', 'Explore the Course')); ?>
                              </a>
                          </div>
                      </div>
                  </div>
              </div>
          </div>
          <!-- </div> -->
          <?php endwhile;
            wp_reset_postdata(); ?>
          <?php } } ?>
          <div class="clear"></div> 

        <?php else : ?>

          <?php for ( $i = 1; $i <= 3; $i++ ) : ?>
            <div class="mini_golfswiper-slide">
                <div class="mini_golfslide-inner slide-bg-image">
                    <div class="sliderimg">

                        <img class="slide-mainimg slidershape1" 
                            src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/bannerimg.png' ); ?>" 
                            alt="<?php esc_attr_e('Default Slide','mini-golf'); ?>">

                        <div class="slider-olay"></div>

                        <div class="slidercontent">

                            <div class="sub-title">
                                <?php esc_html_e('Est. 1923','mini-golf'); ?>
                            </div>

                            <h2><?php esc_html_e('Welcome to Our Website','mini-golf'); ?></h2>

                            <div class="slide-text">
                                <p><?php esc_html_e('Set up your slider from the Customizer.','mini-golf'); ?></p>
                            </div>

                            <div class="slide-btns">
                                <a class="contactus" href="#"><?php esc_html_e('Learn More','mini-golf'); ?></a>
                                <a class="ReadMore" href="#"><?php esc_html_e('Explore','mini-golf'); ?></a>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
          <?php endfor; ?>

        <?php endif; ?>

      </div>
       <!-- swipper controls -->
      <div class="mini_golfswiper-pagination"></div>
      <div class="mini_golfswiper-button-next">
        <i class="fa-solid fa-caret-left"></i>
      </div>
      <div class="mini_golfswiper-button-prev">
        <i class="fa-solid fa-caret-left"></i>
      </div>
    </div>
  </section>
   <div class="bottom-fade"></div>
  <!-- end of hero slider -->
</section>


