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

get_header(); ?>

<main id="skip-content">
  <?php if(get_theme_mod('architect_engineer_top_slider_setting',true)){ ?>
    <section id="top-slider" slider-loop="<?php echo esc_html(get_theme_mod('architect_engineer_slider_loop')); ?>">
      <?php $architect_engineer_slide_pages = array();
        for ( $architect_engineer_count = 1; $architect_engineer_count <= 3; $architect_engineer_count++ ) {
          $architect_engineer_mod = intval( get_theme_mod( 'architect_engineer_top_slider_page' . $architect_engineer_count ));
          if ( 'page-none-selected' != $architect_engineer_mod ) {
            $architect_engineer_slide_pages[] = $architect_engineer_mod;
          }
        }
        if( !empty($architect_engineer_slide_pages) ) :
          $architect_engineer_args = array(
            'post_type' => 'page',
            'post__in' => $architect_engineer_slide_pages,
            'orderby' => 'post__in'
          );
          $architect_engineer_query = new WP_Query( $architect_engineer_args );
          if ( $architect_engineer_query->have_posts() ) :
            $i = 1;
      ?>
      <div class="owl-carousel" role="listbox">
        <?php  while ( $architect_engineer_query->have_posts() ) : $architect_engineer_query->the_post(); ?>
          <div class="slider-box">
            <div class="row">
              <div class="col-lg-6 col-md-6 col-sm-6 align-self-center">
                <?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="col-lg-6 col-md-6 col-sm-6 align-self-center position-relative">
                <div class="slider-inner-box">
                  <?php if(get_theme_mod('architect_engineer_slider_title_setting',1) == 1){ ?>
                    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                  <?php }?>
                  <?php if(get_theme_mod('architect_engineer_slider_content_setting',1) == 1){ ?>
                    <p><?php echo wp_trim_words( get_the_content(), esc_attr(get_theme_mod('architect_engineer_slider_excerpt_length', 30)) ); ?></p>
                  <?php }?>
                  <?php if(get_theme_mod('architect_engineer_slider_button_setting',1) == 1 && get_theme_mod('architect_engineer_slider_button_text','Read More') != ''){ ?>
                    <div class="slider-box-btn mt-4">
                      <a href="<?php the_permalink(); ?>"><?php esc_html_e(get_theme_mod('architect_engineer_slider_button_text','Read More')); ?></a>
                    </div>
                  <?php }?>
                </div>
              </div>
            </div>
          </div>
        <?php $i++; endwhile;
        wp_reset_postdata();?>
      </div>
      <?php else : ?>
        <div class="no-postfound"></div>
      <?php endif;
      endif;?>
    </section>
  <?php }?>

  <section class="latest-project py-5">
    <div class="container">
      <?php if(get_theme_mod('architect_engineer_projects_short_title') != ''){ ?>
        <h6 class="text-center"><?php echo esc_html(get_theme_mod('architect_engineer_projects_short_title','')); ?></h6>
      <?php }?>
      <?php if(get_theme_mod('architect_engineer_projects_title') != ''){ ?>
        <h3 class="mb-4 text-center"><?php echo esc_html(get_theme_mod('architect_engineer_projects_title','')); ?></h3>
      <?php }?>
      <div class="row">
        <?php
          $architect_engineer_projects_cat = get_theme_mod('architect_engineer_projects_category','');
          $architect_engineer_projects_per_page = get_theme_mod('architect_engineer_projects_per_page','3');
          if($architect_engineer_projects_cat){
            $architect_engineer_page_query5 = new WP_Query(array( 'category_name' => esc_html($architect_engineer_projects_cat,'architect-engineer'),'post_per_page' => esc_attr( $architect_engineer_projects_per_page )));
            $i=1;
            while( $architect_engineer_page_query5->have_posts() ) : $architect_engineer_page_query5->the_post(); ?>
              <div class="col-lg-4 col-md-6 col-sm-6">
                <div class="box mb-5">
                  <?php if ( has_post_thumbnail() ) { ?>
                    <div class="box-image">
                      <div class="ffsfs">
                        <div class="fsdffsd">
                          <?php the_post_thumbnail(); ?>
                        </div>
                      </div>
                    </div>
                  <?php }?>
                  <div class="box-content">
                      <h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                      <p class="post mb-0"><?php echo esc_html( wp_trim_words( get_the_content(), 10 )); ?></p>
                  </div>
                </div>
              </div>
            <?php $i++; endwhile;
          wp_reset_postdata();
        } ?>
      </div>
    </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(); ?>
