<?php
/**
 * Template Name: Custom Home Page
 */
get_header(); ?>

<main id="content">
    <?php if( get_option('electrician_services_slider_arrows', false) !== 'off'){ ?>
      <section id="slider">
        <div class="container">
          <div class="slider-overlay">
            <div class="owl-carousel">
            <?php
              $electrician_services_slider_category=  get_theme_mod('electrician_services_post_setting');if($electrician_services_slider_category){
              $electrician_services_page_query = new WP_Query(array( 

                    'category_name' => esc_html($electrician_services_slider_category ,'electrician-services'),

                    'posts_per_page' => get_theme_mod('electrician_services_slider_count')

                  ));?>
                <?php while( $electrician_services_page_query->have_posts() ) : $electrician_services_page_query->the_post(); ?>
                <div class="slide-box">
                  <?php if(has_post_thumbnail()){ ?>
                    <img src="<?php the_post_thumbnail_url('full'); ?>"/>
                  <?php }else{?>
                    <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/slider.jpg" alt="" />
                  <?php } ?>
                  <div class="slide-inner-box slider-inner">
                    <?php if( get_theme_mod('electrician_services_slide_heading') != ''){ ?>
                      <h3><?php echo esc_html(get_theme_mod('electrician_services_slide_heading','')); ?></h3>
                    <?php }?>
                    <h2 class="slider-title"><?php the_title();?></h2>
                    <?php if( get_option('electrician_services_slider_excerpt_show_hide',true) != 'off'){ ?>
                      <p class="slider-excerpt mb-0"><?php echo wp_trim_words(get_the_content(), get_theme_mod('electrician_services_slider_excerpt_count',30) );?></p>
                    <?php } ?>
                    <div class="home-btn my-4">
                      <a href="<?php the_permalink(); ?>"><?php echo esc_html(get_theme_mod('electrician_services_slider_read_more',__('Read More','electrician-services'))); ?></a>
                    </div>
                  </div>
                </div>
                <?php endwhile;
              wp_reset_postdata();
            }?>
            </div>
          </div>
        </div>
      </section>
    <?php }?>
    <?php if( get_option('electrician_services_project_enable', false) !== 'off'){ ?>
      <section id="home-about" class="py-5">
        <div class="container">
          <div class="row">
            <div class="col-lg-4 col-md-5 col-sm-5 align-self-center wow zoomIn">
              <?php if( get_theme_mod('electrician_services_project_text') != ''){ ?>
                <h6><?php echo esc_html(get_theme_mod('electrician_services_project_text','')); ?></h6>
              <?php }?>
              <?php if( get_theme_mod('electrician_services_project_heading') != ''){ ?>
                <h3><?php echo esc_html(get_theme_mod('electrician_services_project_heading','')); ?></h3>
              <?php }?>
              <?php if( get_theme_mod('electrician_services_project_btn_url') != ''){ ?>
                <div class="home-btn text-center text-sm-start my-4">
                  <a href="<?php echo esc_html(get_theme_mod('electrician_services_project_btn_url','')); ?>"><?php esc_html_e('View All Projects','electrician-services'); ?></a>
                </div>
              <?php }?>
            </div>
            <div class="col-lg-8 col-md-7 col-sm-7 align-self-center">
              <div class="owl-carousel">
                <?php
                  $electrician_services_project_category=  get_theme_mod('electrician_services_project_setting');if($electrician_services_project_category){
                  $electrician_services_page_query = new WP_Query(array( 

                    'category_name' => esc_html($electrician_services_project_category ,'electrician-services'),

                    'posts_per_page' => get_theme_mod('electrician_services_project_count')

                  ));?>
                    <?php while( $electrician_services_page_query->have_posts() ) : $electrician_services_page_query->the_post(); ?>
                    <div class="project-box">
                      <?php if(has_post_thumbnail()){ ?>
                        <?php the_post_thumbnail(); ?>
                      <?php }?>
                      <div class="project-inner-box">
                        <h4><?php the_title();?></h4>
                        <p class="mb-0"><?php echo esc_html(wp_trim_words(get_the_content(),'15') );?></p>
                      </div>
                    </div>
                    <?php endwhile;
                  wp_reset_postdata();
                }?>
              </div>
            </div>
          </div>
        </div>
      </section>
    <?php }?>
    <section id="custom-page-content" <?php if ( have_posts() && trim( get_the_content() ) !== '' ) echo 'class="pt-3"'; ?>>
    <div class="container">
      <?php while ( have_posts() ) : the_post(); ?>
        <?php the_content(); ?>
      <?php endwhile; ?>
    </div>
  </section>
</main>

<?php get_footer(); ?>
