<?php
/**
 * Template Name: Home Template
 */

get_header(); ?>

<main id="skip-content">
  <?php if (get_theme_mod('deep_cleaning_slider_section_setting', true) != '') { ?>
    <section id="top-slider">
      <div class="background-color-box"></div>
      <div class="">
        <div class=" slider-right">
          <?php $deep_cleaning_slide_pages = array();
            for ( $deep_cleaning_count = 1; $deep_cleaning_count <= 3; $deep_cleaning_count++ ) {
              $deep_cleaning_mod = intval( get_theme_mod( 'deep_cleaning_top_slider_page' . $deep_cleaning_count ));
              if ( 'page-none-selected' != $deep_cleaning_mod ) {
                $deep_cleaning_slide_pages[] = $deep_cleaning_mod;
              }
            }
            if( !empty($deep_cleaning_slide_pages) ) :
              $deep_cleaning_args = array(
                'post_type' => 'page',
                'post__in' => $deep_cleaning_slide_pages,
                'orderby' => 'post__in'
              );
              $deep_cleaning_query = new WP_Query( $deep_cleaning_args );
              if ( $deep_cleaning_query->have_posts() ) :
                $i = 1;
          ?>
          <div id="combinedCarousel" class="owl-carousel" role="listbox">
            <?php  while ( $deep_cleaning_query->have_posts() ) : $deep_cleaning_query->the_post(); ?>
              <div class="slide-box row m-0">
                <div class="col-xl-7 col-lg-7 col-md-7 col-sm-7 align-self-center">
                  <div class="slider-inner-box">
                    <a href="<?php the_permalink(); ?>"><h3 class="m-0"><?php the_title(); ?></h3></a>
                    <p class="content mt-3"><?php echo esc_html( wp_trim_words( get_the_content(),20 )); ?><p>
                    <div class="slide-btn mt-4">
                      <a class="me-2" href="<?php the_permalink(); ?>"><?php esc_html_e('Contact Us Today','deep-cleaning'); ?><i class="fas fa-arrow-right"></i></a>
                    </div>
                  </div>
                </div>
                <div class="col-xl-5 col-lg-5 col-md-5 col-sm-5 align-self-center slider-image">
                  <?php if(has_post_thumbnail()){
                      the_post_thumbnail();
                      } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
                  <?php } ?>
                </div>
              </div>
            <?php $i++; endwhile;
             wp_reset_postdata();?>
            <?php else : ?>
            <div class="no-postfound"></div>
            <?php endif;
            endif;?>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

  <?php if (get_theme_mod('deep_cleaning_categories_section_setting', true) != '') { ?>
    <section id="top-categories" class="py-5">
      <div class="container">
        <div class="categorie-heading mt-5">
          <?php if(get_theme_mod('deep_cleaning_team_heading') != ''){ ?>
            <h4 class="main-heading mb-2"><?php echo esc_html(get_theme_mod('deep_cleaning_team_heading')); ?></h4>
          <?php }?>
          <?php if(get_theme_mod('deep_cleaning_team_content') != ''){ ?>
            <p class="main-heading"><?php echo esc_html(get_theme_mod('deep_cleaning_team_content')); ?></p>
          <?php }?>
        </div>
        <div class="owl-carousel mt-4 ser-box pb-5">
          <?php
            $deep_cleaning_services_cat = get_theme_mod('deep_cleaning_services_sec_category','');
            if($deep_cleaning_services_cat){
              $deep_cleaning_page_query5 = new WP_Query(array( 'category_name' => esc_html($deep_cleaning_services_cat,'deep-cleaning'),'posts_per_page' => 8));
              $i=1;
              while( $deep_cleaning_page_query5->have_posts() ) : $deep_cleaning_page_query5->the_post(); ?>
                <div class="service-box">
                  <div class=" service-icon align-self-center ps-0">
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail();
                      } else{?>
                      <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/teambg.png"/>
                    <?php } ?>
                  </div>
                  <div class="team-content">
                    <div class="row m-0">
                      <div class="col-lg-9 col-md-9 col-sm-9 col-9 align-self-center">
                        <h4 class="m-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                      </div>
                      <div class="col-lg-3 col-md-3 col-sm-3 col-3 align-self-center arrow-button text-end">
                        <a class="category-title" href="<?php the_permalink(); ?>">
                          <i class="fas fa-arrow-right ms-2"></i>
                        </a>
                      </div>
                    </div>
                  </div>
                </div>
              <?php $i++; endwhile;
            wp_reset_postdata();
          } ?>
        </div>
      </div>
    </section>
  <?php }?>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>