<?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 Classic Digital Marketing
 */

get_header(); ?>

<div id="content" >

<?php
    $classic_digital_marketing_hidcatslide = get_theme_mod('classic_digital_marketing_hide_categorysec', false);
    $classic_digital_marketing_slidersection = get_theme_mod('classic_digital_marketing_slidersection');

    if ($classic_digital_marketing_hidcatslide && $classic_digital_marketing_slidersection) { ?>
    <section id="slider">
      <div class="main-slider">
        <div class="owl-carousel owl-theme slider-sec">
          <?php if( get_theme_mod('classic_digital_marketing_slidersection',false) ) { ?>
            <?php $classic_digital_marketing_queryvar = new WP_Query('cat='.esc_attr(get_theme_mod('classic_digital_marketing_slidersection',false)));
              while( $classic_digital_marketing_queryvar->have_posts() ) : $classic_digital_marketing_queryvar->the_post(); ?>
            <div class="item">
              <div class="content d-flex align-items-center" style="background-image: url(<?php 
                if (has_post_thumbnail()) {
                  echo the_post_thumbnail_url('full');
                } else {
                  echo esc_url(get_template_directory_uri() . '/images/slider-img.png');
                }
                ?>);">
                <div class="sliderbox">
                  <?php if(get_theme_mod('classic_digital_marketing_slider_top_text') != ''){ ?>
                    <p class="slider-text mb-0"><?php echo esc_html(get_theme_mod('classic_digital_marketing_slider_top_text')); ?></p>
                  <?php }?>
                  <h1 class="title-slider mb-3 mt-md-3">
                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                  </h1>
                  <?php
                    $classic_digital_marketing_trimexcerpt = get_the_excerpt();
                    $classic_digital_marketing_shortexcerpt = wp_trim_words( $classic_digital_marketing_trimexcerpt, $classic_digital_marketing_num_words = 20 );
                    echo '<p class="mt-2">' . esc_html( $classic_digital_marketing_shortexcerpt ) . '</p>';
                  ?>
                  <div class="sliderbtn mt-lg-4">
                    <?php 
                    $classic_digital_marketing_button_text = get_theme_mod('classic_digital_marketing_button_text', 'Read More');
                    $classic_digital_marketing_button_link = get_theme_mod('classic_digital_marketing_button_link_slider', ''); 
                    if (empty($classic_digital_marketing_button_link)) {
                        $classic_digital_marketing_button_link = get_permalink();
                    }
                    if ($classic_digital_marketing_button_text || !empty($classic_digital_marketing_button_link)) { ?>
                        <div class="slide-btn">
                          <a href="<?php echo esc_url($classic_digital_marketing_button_link); ?>" class="button redmor">
                            <?php echo esc_html($classic_digital_marketing_button_text); ?>
                              <span class="screen-reader-text"><?php echo esc_html($classic_digital_marketing_button_text); ?></span>
                          </a>
                        </div>
                    <?php } ?>
                  </div>
                </div>
                <div class="overlayer"></div>
              </div>
            </div>
            <?php endwhile; wp_reset_postdata(); ?>
          <?php } ?>
        </div>
      </div>
    </section>
<?php } ?>

<?php
  $classic_digital_marketing_hidepageboxes = get_theme_mod('classic_digital_marketing_disabled_pgboxes',false);
  $classic_digital_marketing_blog_cat = get_theme_mod('classic_digital_marketing_blog_cat');

  if ($classic_digital_marketing_hidepageboxes && $classic_digital_marketing_blog_cat) { ?>

    <section id="blog" class="my-5">
      <div class="container">
        <div class="blog_bx text-center">
          <?php if ( get_theme_mod('classic_digital_marketing_headingtext_para') != "") { ?>
            <h2 class="mb-3"><?php echo esc_html(get_theme_mod('classic_digital_marketing_headingtext_para','classic-digital-marketing')); ?></h2>
          <?php }?>
        </div>
        <div class="row">
          <?php if( get_theme_mod('classic_digital_marketing_blog_cat') ) { ?>

          <?php $classic_digital_marketing_queryvar = new WP_Query(
            array( 
              'cat' => esc_attr(get_theme_mod('classic_digital_marketing_blog_cat')),
            )
          );
          while( $classic_digital_marketing_queryvar->have_posts() ) : $classic_digital_marketing_queryvar->the_post(); ?>
          <div class="col-lg-3 col-md-6 service-box my-3">
              <div class="team-box">
                  <?php if (has_post_thumbnail()) : ?>
                    <?php the_post_thumbnail(); ?>
                  <?php else : ?>
                      <div class="post-color"></div>
                  <?php endif; ?>
                  <div class="blog-content px-3 py-2 text-center <?php if (!has_post_thumbnail()) echo ' no-thumbnail'; ?>">
                    <h3 class="mt-1 mb-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                  </div>
              </div>
          </div>
          <?php endwhile; wp_reset_postdata(); ?>
          <?php } ?>
        </div>
      </div>
    </section>

<?php }?>

<?php get_footer(); ?>