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

get_header(); 

$kitchen_interior_design_banner_backgroud_image = get_theme_mod('kitchen_interior_design_banner_background_image');
?>

<?php if (get_theme_mod('kitchen_interior_design_slider_section_setting', false) != '') { ?>
  <section id="top-slider" style="background-image: url( <?php echo esc_url( $kitchen_interior_design_banner_backgroud_image ); ?> ) ">
    <?php $kitchen_interior_design_slide_pages = array();
      for ( $kitchen_interior_design_count = 1; $kitchen_interior_design_count <= 3; $kitchen_interior_design_count++ ) {
        $kitchen_interior_design_mod = intval( get_theme_mod( 'kitchen_interior_design_top_slider_page' . $kitchen_interior_design_count ));
        if ( 'page-none-selected' != $kitchen_interior_design_mod ) {
          $kitchen_interior_design_slide_pages[] = $kitchen_interior_design_mod;
        }
      }
      if( !empty($kitchen_interior_design_slide_pages) ) :
        $kitchen_interior_design_args = array(
          'post_type' => 'page',
          'post__in' => $kitchen_interior_design_slide_pages,
          'orderby' => 'post__in'
        );
        $kitchen_interior_design_query = new WP_Query( $kitchen_interior_design_args );
        if ( $kitchen_interior_design_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="container">
      <div class="slider-box">
      <div class="owl-carousel main-carousel">
        <?php  while ( $kitchen_interior_design_query->have_posts() ) : $kitchen_interior_design_query->the_post(); ?>
          <div class="slide-box">
            <div class="slider-image">
              <?php if(has_post_thumbnail()){
                the_post_thumbnail();
                } else{?>
                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider1.png" alt="" />
              <?php } ?>
            </div>
            <div class="slider-inner-box">
              <?php if(get_theme_mod('kitchen_interior_design_slider_short_heading') != ''){ ?>
                <h5 class="main-heading mb-2"><?php echo esc_html(get_theme_mod('kitchen_interior_design_slider_short_heading')); ?></h5>
              <?php }?>
              <h3 class="m-0 mb-4"><?php the_title(); ?></h3>
              <p class="content mt-3"><?php echo esc_html( wp_trim_words( get_the_content(), esc_attr(get_theme_mod('kitchen_interior_design_slider_excerpt_length', 15)) )); ?></p>
              <div class="slide-btn mt-4">
                <a href="<?php the_permalink(); ?>"><?php esc_html_e('Discover More','kitchen-interior-design'); ?> <i class="fas fa-arrow-right ms-2"></i></a>
              </div>
            </div>
          </div>
        <?php $i++; endwhile;
        wp_reset_postdata();?>
      </div>
      </div>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>
  </section>
<?php }?>

<?php if (get_theme_mod('kitchen_interior_design_activities_section_setting', false) != '') { ?>
  <section class="featured py-5" id="skip-content">
    <div class="container ">
      <div class="heading text-center mb-4">
        <?php if(get_theme_mod('kitchen_interior_design_services_heading') != ''){ ?>
          <h4 class="main-heading mb-3"><?php echo esc_html(get_theme_mod('kitchen_interior_design_services_heading')); ?></h4>
        <?php }?>
        <?php if(get_theme_mod('kitchen_interior_design_services_content') != ''){ ?>
          <h3 class="main-heading"><?php echo esc_html(get_theme_mod('kitchen_interior_design_services_content')); ?></h3>
        <?php }?>
      </div>
      <div class="owl-carousel ser-box">
        <?php
          $kitchen_interior_design_services_cat = get_theme_mod('kitchen_interior_design_services_sec_category','');
          if($kitchen_interior_design_services_cat){
            $kitchen_interior_design_page_query5 = new WP_Query(array( 'category_name' => esc_html($kitchen_interior_design_services_cat,'kitchen-interior-design'),'posts_per_page' => 6));
            $i=1;
            while( $kitchen_interior_design_page_query5->have_posts() ) : $kitchen_interior_design_page_query5->the_post(); ?>
              <?php if(get_theme_mod('kitchen_interior_design_services_icon'.$i,'fas fa-stethoscope')){ ?>
                <div class="ser-content text-center">
                  <div class="service-icon mb-3">
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail();
                      } else{?>
                      <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider1.png" alt="" />
                    <?php } ?>
                  </div>
                  <?php 
                    $categories = get_the_category();
                    if ( ! empty( $categories ) ) {
                      echo '<span class="project-cat">' . esc_html( $categories[0]->name ) . '</span>'; 
                    }
                    ?>
                  <h4 class="my-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                </div>
              <?php }?>
            <?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>

<?php get_footer(); ?>