<?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 Wedding
 */

get_header(); ?>

<div id="content">
  <?php
    $classic_wedding_hidcatslide = get_theme_mod('classic_wedding_hide_categorysec', true);
    $classic_wedding_slidersection = get_theme_mod('classic_wedding_slidersection');

    if ($classic_wedding_hidcatslide && $classic_wedding_slidersection) { ?>
    <section id="catsliderarea">
      <div class="catwrapslider">
        <div class="owl-carousel">
          <?php if( get_theme_mod('classic_wedding_slidersection',false) ) { ?>
            <?php $classic_wedding_queryvar = new WP_Query(
              array(
                'cat' => esc_attr(get_theme_mod('classic_wedding_slidersection',false)),
                'posts_per_page' => esc_attr(get_theme_mod('classic_wedding_slider_count',false))
              )
            );
            while( $classic_wedding_queryvar->have_posts() ) : $classic_wedding_queryvar->the_post(); ?>
              <div class="slidesection">
                <?php if(has_post_thumbnail()){
                  the_post_thumbnail('full');
                  } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'classic-wedding'); ?>"/>
                <?php } ?>
                <div class="slider-box text-center">
                  <h1><a href="<?php echo esc_url( get_permalink() );?>"><?php the_title(); ?></a></h1>
                  <?php
                    $classic_wedding_trimexcerpt = get_the_excerpt();
                    $classic_wedding_shortexcerpt = wp_trim_words( $classic_wedding_trimexcerpt, $num_words = 15 );
                    echo '<p class="mt-4">' . esc_html( $classic_wedding_shortexcerpt ) . '</p>';
                  ?>
                  <div class="slide-btn mt-lg-5 mt-2">
                    <?php 
                    $classic_wedding_button_text = get_theme_mod('classic_wedding_button_text', 'Book Now');
                    $classic_wedding_button_link_slider = get_theme_mod('classic_wedding_button_link_slider', ''); 
                    if (empty($classic_wedding_button_link_slider)) {
                        $classic_wedding_button_link_slider = get_permalink();
                    }
                    if ($classic_wedding_button_text || !empty($classic_wedding_button_link_slider)) { ?>
                      <?php if(get_theme_mod('classic_wedding_button_text','Book Now') != ''){ ?>
                        <a href="<?php echo esc_url($classic_wedding_button_link_slider); ?>">
                          <?php echo esc_html($classic_wedding_button_text); ?>
                            <span class="screen-reader-text"><?php echo esc_html($classic_wedding_button_text); ?></span>
                        </a>
                      <?php } ?>
                    <?php } ?>
                  </div>
                </div>
              </div>
            <?php endwhile; wp_reset_postdata(); ?>
          <?php } ?>
        </div>
      </div>
    </section>
  <?php } ?>

  <?php
      $classic_wedding_show_abt_sec = get_theme_mod('classic_wedding_show_abt_sec', true);
      $classic_wedding_about_us = get_theme_mod('classic_wedding_about_us');

      if ($classic_wedding_show_abt_sec && $classic_wedding_about_us) { ?>
    <section class="about_us text-center">
      <div class="container">
        <?php $classic_wedding_querymed = new WP_query('page_id='.esc_attr(get_theme_mod('classic_wedding_about_us',false)) ); ?>
          <?php while( $classic_wedding_querymed->have_posts() ) : $classic_wedding_querymed->the_post(); ?>
            <div class="img-inner-box mb-5">
              <?php if (has_post_thumbnail() ){ ?><?php the_post_thumbnail();?><?php } ?>
            </div>
            <div class="content-inner-box">
              <?php if ( get_theme_mod('classic_wedding_pgboxes_title') != "") { ?>
                <div class="title-img"></div>
                <span><?php echo esc_html(get_theme_mod('classic_wedding_pgboxes_title','')); ?></span>
              <?php } ?>
              <h2 class="py-3"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h2>
              <p><?php echo esc_html( wp_trim_words( get_the_content(), 40, '...' ) );  ?></p>
            </div>
          <?php endwhile; wp_reset_postdata(); ?>
        <div class="clear"></div>
      </div>
    </section>
  <?php } ?>

</div>

<?php get_footer(); ?>
