<?php
/**
 * Template part for displaying offer section
 *
 * @package Travel Hub
 * @subpackage travel_hub
 */

?>
<?php $travel_hub_static_image = get_template_directory_uri() . '/assets/images/sliderimage.png'; ?>

<?php if( get_theme_mod( 'travel_hub_offer_show_hide', true) != '') { ?>
<section id="travel-offer">
  <div class="container">
    <?php if( get_theme_mod('travel_hub_offer_section_short_title') != ''){ ?>
      <p class="offer-top"><?php echo esc_html(get_theme_mod('travel_hub_offer_section_short_title','')); ?></p>
    <?php }?>
    <?php if( get_theme_mod('travel_hub_offer_section_tittle') != ''){ ?>
      <h2><?php echo esc_html(get_theme_mod('travel_hub_offer_section_tittle','')); ?></h2>
    <?php }?>
    <?php if( get_theme_mod('travel_hub_offer_section_text') != ''){ ?>
      <p class="my-3"><?php echo esc_html(get_theme_mod('travel_hub_offer_section_text','')); ?></p>
    <?php }?>
    <div class="row">
      <?php
        $travel_hub_post_category = get_theme_mod('travel_hub_offer_section_category');
        if($travel_hub_post_category){
          $travel_hub_page_query = new WP_Query(array( 'category_name' => esc_html( $travel_hub_post_category ,'travel-hub')));?>
          <?php while( $travel_hub_page_query->have_posts() ) : $travel_hub_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="'.$travel_hub_static_image .'">'); } ?>
                    <?php if( get_post_meta($post->ID, 'travel_hub_trip_amount', true) ) {?>
                      <p class="sub-head"><?php echo esc_html(get_post_meta($post->ID,'travel_hub_trip_amount',true)); ?></p>
                    <?php }?>
                  </div>
                  <div class="col-lg-6 col-md-6 align-self-center py-md-1">
                    <div class="offer-box px-3">
                      <h3><a class="title-offer" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                      <?php if( get_post_meta($post->ID, 'travel_hub_trip_days', true) ) {?>
                        <span class="mt-1"><i class="far fa-clock mr-2"></i><?php echo esc_html(get_post_meta($post->ID,'travel_hub_trip_days',true)); ?></span>
                      <?php }?>
                      <p class="mt-3"><?php echo wp_trim_words( get_the_content(),15 );?></p>   
                      <div class="my-3">
                        <a href="<?php the_permalink(); ?>"><?php esc_html_e('LEARN MORE','travel-hub'); ?></a>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        }
      ?>
    </div>
  </div>
</section>
<?php }?>