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

get_header(); ?>

<main id="skip-content">
  <section id="top-slider" >
    <?php $wooden_furniture_slide_pages = array();
      for ( $wooden_furniture_count = 1; $wooden_furniture_count <= 3; $wooden_furniture_count++ ) {
        $wooden_furniture_mod = intval( get_theme_mod( 'wooden_furniture_top_slider_page' . $wooden_furniture_count ));
        if ( 'page-none-selected' != $wooden_furniture_mod ) {
          $wooden_furniture_slide_pages[] = $wooden_furniture_mod;
        }
      }
      if( !empty($wooden_furniture_slide_pages) ) :
        $wooden_furniture_args = array(
          'post_type' => 'page',
          'post__in' => $wooden_furniture_slide_pages,
          'orderby' => 'post__in'
        );
        $wooden_furniture_query = new WP_Query( $wooden_furniture_args );
        if ( $wooden_furniture_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="owl-carousel" role="listbox">
      <?php  while ( $wooden_furniture_query->have_posts() ) : $wooden_furniture_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/slider.png" alt="" />
            <?php } ?>
          </div>
          <div class="slider-inner-box">
            <?php if(get_theme_mod('wooden_furniture_slider_short_heading') != ''){ ?>
              <h5 class="main-heading "><?php echo esc_html(get_theme_mod('wooden_furniture_slider_short_heading')); ?></h5>
            <?php }?>
            <h3 class="m-0 mb-4 pb-3"><?php the_title(); ?></h3>
            <div class="slide-btn mt-4">
              <a href="<?php the_permalink(); ?>"><?php esc_html_e('View More','wooden-furniture'); ?><i class="fas fa-arrow-right ms-2"></i></a>
            </div>
          </div>
        </div>
      <?php $i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>
  </section>

  <section class="featured pb-5">
    <div class="container">
      <div class="row m-0 ser-box">
        <?php
          $wooden_furniture_services_cat = get_theme_mod('wooden_furniture_services_sec_category','');
          if($wooden_furniture_services_cat){
            $wooden_furniture_page_query5 = new WP_Query(array( 'category_name' => esc_html($wooden_furniture_services_cat,'wooden-furniture'),'posts_per_page' => 3));
            $i=1;
            while( $wooden_furniture_page_query5->have_posts() ) : $wooden_furniture_page_query5->the_post(); ?>
              <?php if(get_theme_mod('wooden_furniture_services_icon'.$i,'fas fa-stethoscope')){ ?>
                <div class="col-lg-4 col-md-4 col-sm-4 p-0 service-box">
                  <div class="feature-box m-0">
                    <div class="ser-content">
                      <div class="service-icon">
                        <i class="<?php echo esc_attr(get_theme_mod('wooden_furniture_services_icon'.$i,'fas fa-stethoscope')); ?> mb-3"></i>
                      </div>
                      <h4 class="my-2 text-lg-start"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                      <p class="content mt-1 m-0"><?php echo esc_html( wp_trim_words( get_the_content(),25 )); ?><p>
                    </div>
                  </div>
                </div>
              <?php }?>
            <?php $i++; endwhile;
          wp_reset_postdata();
        } ?>
      </div>
    </div>
  </section>
  <section class="contact py-5">
    <div class="container">
      <?php if(get_theme_mod('wooden_furniture_services_heading') != '' || get_theme_mod('wooden_furniture_services_content') != '' || get_theme_mod('wooden_furniture_contact_form_shortcode') != '' ){ ?>
        <div class="row m-0 contact-box">
          <div class="col-lg-4 align-self-center">
            <?php if(get_theme_mod('wooden_furniture_services_heading') != ''){ ?>
              <h3 class="main-heading "><?php echo esc_html(get_theme_mod('wooden_furniture_services_heading')); ?></h3>
            <?php }?>
            <?php if(get_theme_mod('wooden_furniture_services_content') != ''){ ?>
              <p class="main-heading"><?php echo esc_html(get_theme_mod('wooden_furniture_services_content')); ?></p>
            <?php }?>
          </div>
          <div class="col-lg-8 align-self-center form-box">
            <?php if(get_theme_mod('wooden_furniture_contact_form_shortcode')){ ?>
              <?php echo do_shortcode(get_theme_mod('wooden_furniture_contact_form_shortcode')); ?>
            <?php }?>
          </div>
        </div>
      <?php }?>
    </div>
  </section>
  <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(); ?>