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

?>
<!-- banner section -->
<main id="maincontent" role="main">
  <?php do_action( 'vw_machine_learning_above_banner' ); ?>
  <?php if (get_theme_mod('vw_machine_learning_hide_show_banner_section', true)== 1 || get_theme_mod( 'vw_machine_learning_resp_slider_hide_show', true) == 1) { ?>
    <section id="banner-sec">
      <div class="banner-img position-relative">
        <?php if (get_theme_mod('vw_machine_learning_banner_bg_img') != "") { ?>
          <div class="banner-bg-img position-relative">
            <img src="<?php echo esc_url(get_theme_mod('vw_machine_learning_banner_bg_img')); ?>" alt="<?php echo esc_attr('Background Image', 'vw-machine-learning'); ?>">
          </div>
        <?php } else { ?>
          <div class="banner-bg-img position-relative">
            <img src="<?php echo esc_url(get_template_directory_uri()) ?>/assets/images/banner-img.png" alt="<?php echo esc_attr('Background Image', 'vw-machine-learning'); ?>">
          </div>
        <?php } ?>
        <div class="banner-content position-absolute">
          <div class="container">
            <div class="row">
              <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-12 align-self-center banner-text-box">
                <?php if (get_theme_mod('vw_machine_learning_banner_small_title') != '') { ?>
                  <p class="banner-sml-title text-capitalize"><?php echo esc_html(get_theme_mod('vw_machine_learning_banner_small_title')); ?></p>
                <?php } ?>
                <?php if (get_theme_mod('vw_machine_learning_banner_title') != '') { ?>
                  <h1 class="banner-title text-capitalize"><?php echo esc_html(get_theme_mod('vw_machine_learning_banner_title')); ?></h1>
                <?php } ?>
                <?php if (get_theme_mod('vw_machine_learning_banner_text') != '') { ?>
                  <p class="banner-text mb-5 mt-3"><?php echo esc_html(get_theme_mod('vw_machine_learning_banner_text')); ?></p>
                <?php } ?>
                <?php if ( get_theme_mod('vw_machine_learning_banner_button_label') != '' ) {?>
                  <div class ="banner-btn">
                    <a href="<?php echo esc_url(get_theme_mod('vw_machine_learning_banner_button_url'));?>" class="text-capitalize"><?php echo esc_html(get_theme_mod('vw_machine_learning_banner_button_label'));?>
                    </a>
                  </div>
                <?php }?>
              </div>
              <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-12 align-self-end bnr-img text-center position-relative">
                <?php if (get_theme_mod('vw_machine_learning_banner_side_img') != "") { ?>
                  <img src="<?php echo esc_url(get_theme_mod('vw_machine_learning_banner_side_img')); ?>" alt="<?php echo esc_attr('banner image', 'vw-machine-learning'); ?>">
                <?php }?>
              </div>
            </div>
            <?php if (get_theme_mod('vw_machine_learning_banner_middle_title') != '') { ?>
              <p class="banner-middle text-uppercase position-absolute mb-0"><?php echo esc_html(get_theme_mod('vw_machine_learning_banner_middle_title')); ?></p>
            <?php } ?>
          </div>
        </div>
      </div>
    </section>
  <?php }?>
  <?php do_action( 'vw_machine_learning_below_banner' ); ?>

  <!-- Case Study Section -->
  <?php if (get_theme_mod('vw_machine_learning_case_section_hide_show', true)){ ?>
    <section id="case-section" class="my-4">
      <div class="container">
        <div class="case-sec-content mb-4 text-center">
          <?php if(get_theme_mod('vw_machine_learning_case_section_text') != '') {?>
            <p class="small-text mb-2 text-capitalize"><?php echo esc_html(get_theme_mod('vw_machine_learning_case_section_text')) ?></p>
          <?php }?>
          <?php if(get_theme_mod('vw_machine_learning_case_section_title') != '') {?>
            <h2 class="section-title text-capitalize mb-2"><?php echo esc_html(get_theme_mod('vw_machine_learning_case_section_title')) ?></h2>
          <?php }?>
        </div>
        <div class="row">
          <?php
            $vw_machine_learning_catdata=  get_theme_mod('vw_machine_learning_case_category');
            if($vw_machine_learning_catdata){
            $vw_machine_learning_page_query = new WP_Query(array(
              'category_name' => esc_html($vw_machine_learning_catdata, 'vw-machine-learning'),
              'posts_per_page' => 4
            ));  
          ?>         
          <?php while( $vw_machine_learning_page_query->have_posts() ) : $vw_machine_learning_page_query->the_post(); ?>
            <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 case-main">
              <div class="case-box mb-4">
                <div class="row">
                  <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 align-self-center case-img">
                    <?php if(has_post_thumbnail()){ ?>
                      <?php the_post_thumbnail(); ?>
                    <?php } else {?>
                      <img src="<?php echo esc_url(get_template_directory_uri()) ?>/assets/images/post-image.png" alt="<?php echo esc_attr('Post Image', 'vw-machine-learning'); ?>">
                    <?php }?>
                  </div>
                  <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 align-self-center articles">
                    <div class="blog-category"><?php the_category(); ?></div>
                    <h5 class="case-title text-capitalize mb-0"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></h5>
                    <p class="post-para pt-2 pt-md-2 pt-lg-3">
                      <?php 
                        $vw_machine_learning_excerpt = get_the_excerpt(); 
                        echo esc_html(wp_trim_words($vw_machine_learning_excerpt, 15)); 
                      ?>
                    </p>
                    <div class="case-btn">
                      <a href="<?php the_permalink(); ?>"><?php echo esc_html__('Explore More', 'vw-machine-learning'); ?><span class="screen-reader-text"><?php echo esc_html__('Explore More', 'vw-machine-learning') ?></span></a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          <?php endwhile;
            wp_reset_postdata();
          }?>
        </div>
      </div>
    </section>
  <?php }?>
  <?php do_action( 'vw_machine_learning_after_service' ); ?>

  <div id="content-vw" class="entry-content">
    <div class="container">
      <?php while (have_posts()) : the_post(); ?>
        <?php the_content(); ?>
      <?php endwhile; // end of the loop. 
      ?>
    </div>
  </div>
</main>

<?php get_footer(); ?> 