<?php
/**
 * Template part for displaying offer section
 *
 * @package The Tour Operator
 * @subpackage the_tour_operator
 */

?>
<?php $the_tour_operator_static_image = get_template_directory_uri() . '/assets/images/sliderimage.png'; ?>
<?php if( get_theme_mod( 'the_tour_operator_offer_show_hide', true) != '') { ?>
<section id="travel-offer" class="my-5">
  <div class="container">
    <?php if( get_theme_mod('the_tour_operator_offer_section_short_title') != ''){ ?>
      <p class="offer-title"><?php echo esc_html(get_theme_mod('the_tour_operator_offer_section_short_title','')); ?></h6>
    <?php }?>
    <?php if( get_theme_mod('the_tour_operator_offer_section_tittle') != ''){ ?>
      <h2><?php echo esc_html(get_theme_mod('the_tour_operator_offer_section_tittle','')); ?></h2>
    <?php }?>
    <?php if( get_theme_mod('the_tour_operator_offer_section_text') != ''){ ?>
      <p class="my-3"><?php echo esc_html(get_theme_mod('the_tour_operator_offer_section_text','')); ?></p>
    <?php }?>
    <div class="row">
      <?php
        $the_tour_operator_post_category = get_theme_mod('the_tour_operator_offer_section_category');
        if($the_tour_operator_post_category){
          $the_tour_operator_page_query = new WP_Query(array( 'category_name' => esc_html( $the_tour_operator_post_category ,'the-tour-operator')));?>
          <?php while( $the_tour_operator_page_query->have_posts() ) : $the_tour_operator_page_query->the_post(); ?>
            <div class="col-lg-6 col-md-6">
              <div class="cat-inner-box mb-3">
                <div class="row">
                  <div class="col-lg-6 col-md-6 align-self-center position-relative">
                    <?php if(has_post_thumbnail()) { ?><?php the_post_thumbnail(); ?><?php }else {echo ('<img src="'.$the_tour_operator_static_image .'">'); } ?>
                    <?php if( get_post_meta($post->ID, 'the_tour_operator_trip_amount', true) ) {?>
                      <h4><?php echo esc_html(get_post_meta($post->ID,'the_tour_operator_trip_amount',true)); ?></h4>
                    <?php }?>
                  </div>
                  <div class="col-lg-6 col-md-6 align-self-center py-md-2">
                    <div class="offer-box">
                      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                      <?php if( get_post_meta($post->ID, 'the_tour_operator_trip_days', true) ) {?>
                        <span><i class="far fa-clock mr-2"></i><?php echo esc_html(get_post_meta($post->ID,'the_tour_operator_trip_days',true)); ?></span>
                      <?php }?>
                      <p class="mt-3"><?php echo wp_trim_words( get_the_content(),12 );?></p>   
                      <div class="my-3 offer-btn">
                        <a href="<?php the_permalink(); ?>"><?php esc_html_e('Learn More','the-tour-operator'); ?></a>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        }
      ?>
    </div>
  </div>
</section>
<?php }?>