<?php
/**
 * The Template Name: Home Page
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package Web Startup Agency
 */

get_header(); ?>

<div id="content">
  <?php
    $web_startup_agency_hidcatslide = get_theme_mod('web_startup_agency_hide_categorysec', false);
    $web_startup_agency_pageboxes = get_theme_mod('web_startup_agency_pageboxes');

    if ($web_startup_agency_hidcatslide && $web_startup_agency_pageboxes) { ?>
    <section id="catsliderarea">
      <div class="catwrapslider">
        <div class="owl-carousel">
          <?php if( get_theme_mod('web_startup_agency_pageboxes',false) ) { ?>
          <?php $web_startup_agency_queryvar = new WP_Query('cat='.esc_attr(get_theme_mod('web_startup_agency_pageboxes',false)));
            while( $web_startup_agency_queryvar->have_posts() ) : $web_startup_agency_queryvar->the_post(); ?>
              <div class="slidesection"> 
                <?php if(has_post_thumbnail()){
                    the_post_thumbnail('full');
                    } else{?>
                    <img src="<?php echo esc_url(get_theme_file_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'web-startup-agency'); ?>"/>
                  <?php } ?>
                <div class="slider-box">
                  <div class="slider-content">
                  <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                  <?php
                    $trimexcerpt = get_the_excerpt();
                    $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 35 );
                    echo '<p>' . esc_html( $shortexcerpt ) . '</p>'; 
                  ?>
                  <?php if ( get_theme_mod('web_startup_agency_button_text') != "" || get_theme_mod('web_startup_agency_button_link_slider') != '') { ?>
                    <div class="pagemore">
                      <a href="<?php echo esc_url(get_theme_mod('web_startup_agency_button_link_slider')!= '') ? esc_url(get_theme_mod('web_startup_agency_button_link_slider')) : esc_url(get_permalink()); ?>">
                        <?php echo esc_html(get_theme_mod('web_startup_agency_button_text',__('Read More','web-startup-agency'))); ?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('web_startup_agency_button_text',__('Read More','web-startup-agency'))); ?></span>
                      </a>
                    </div>
                  <?php }?>
                </div>
                </div>
              </div>
            <?php endwhile; wp_reset_postdata(); ?>
          <?php } ?>
        </div>
      </div>
      <div class="clear"></div>
    </section>
  <?php } ?>
  
  <div id="services_section" class="text-center">
    <div class="container">
      <?php if ( get_theme_mod('smallbiz_startup_text') != "") { ?>
        <span><?php echo esc_html(get_theme_mod('smallbiz_startup_text','')); ?></span>
      <?php } ?>
      <?php if ( get_theme_mod('smallbiz_startup_title') != "") { ?>
        <h2><?php echo esc_html(get_theme_mod('smallbiz_startup_title','')); ?></h2>
      <?php } ?>
      <div class="row">
        <?php for($p=1; $p<4; $p++) { ?>
        <?php if( get_theme_mod('smallbiz_startup_pageboxes'.$p,false)) { ?>
          <?php $smallbiz_startup_querymed = new WP_query('page_id='.esc_attr(get_theme_mod('smallbiz_startup_pageboxes'.$p,false)) ); ?>
            <?php while( $smallbiz_startup_querymed->have_posts() ) : $smallbiz_startup_querymed->the_post(); ?>
            <div class="col-lg-4 col-md-4">
              <div class="pagecontent">
                <div class="thumbbx">
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail('full');
                      } else{?>
                      <img src="<?php echo esc_url(get_theme_file_uri()); ?>/images/service-1.png" alt="<?php echo esc_attr( 'image', 'web-startup-agency'); ?>"/>
                    <?php } ?>
                  </div>
                <div class="text-inner-box">
                  <h3 class="text-end"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h3>
                </div>
              </div>
            </div>
          <?php endwhile; wp_reset_postdata(); ?>
        <?php } } ?>
        <div class="clear"></div>
      </div>
    </div>
  </div>

</div>

<?php get_footer(); ?>