<?php
/**
 * Template part for displaying offer section
 *
 * @package Travel Agent
 * @subpackage travel_agent
 */

?>
<?php $travel_agent_static_image = get_template_directory_uri() . '/assets/images/sliderimage.png'; ?>
<?php if( get_theme_mod( 'travel_agent_offer_show_hide', true) != '') { ?>
<section id="travel-offer" class="py-5">
  <div class="container">
    <?php if( get_theme_mod('travel_agent_offer_section_short_title') != ''){ ?>
      <strong><?php echo esc_html(get_theme_mod('travel_agent_offer_section_short_title','')); ?></strong>
    <?php }?>
    <?php if( get_theme_mod('travel_agent_offer_section_tittle') != ''){ ?>
      <h2 class="my-3"><?php echo esc_html(get_theme_mod('travel_agent_offer_section_tittle','')); ?></h2>
    <?php }?>
    <?php if( get_theme_mod('travel_agent_offer_section_text') != ''){ ?>
      <p><?php echo esc_html(get_theme_mod('travel_agent_offer_section_text','')); ?></p>
    <?php }?>
    <div class="row mt-4">
      <?php
        $travel_agent_post_category = get_theme_mod('travel_agent_offer_section_category');
        if($travel_agent_post_category){
          $travel_agent_page_query = new WP_Query(array( 'category_name' => esc_html( $travel_agent_post_category ,'travel-agent')));?>
          <?php while( $travel_agent_page_query->have_posts() ) : $travel_agent_page_query->the_post(); ?>
            <div class="col-lg-4 col-md-6 col-sm-6">
              <div class="cat-inner-box mb-3">
                <?php if(has_post_thumbnail()) { ?><?php the_post_thumbnail(); ?><?php }else {echo ('<img src="'.$travel_agent_static_image .'">'); } ?>   
                <?php if( get_post_meta($post->ID, 'travel_agent_trip_amount', true) ) {?>
                  <h4><?php echo esc_html(get_post_meta($post->ID,'travel_agent_trip_amount',true)); ?></h4>
                <?php }?>
                <div class="offer-box p-3">
                  <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                  <?php if( get_post_meta($post->ID, 'travel_agent_trip_days', true) ) {?>
                    <span><i class="far fa-clock me-2"></i><?php echo esc_html(get_post_meta($post->ID,'travel_agent_trip_days',true)); ?></span>
                  <?php }?>
                  <p class="mt-3 mb-1"><?php echo wp_trim_words( get_the_content(),12 );?></p>   
                  <div class="my-3 text-right serv-btn">
                    <a href="<?php the_permalink(); ?>"><?php esc_html_e('Learn More','travel-agent'); ?></a>
                  </div>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        }?>
    </div>
  </div>
</section>
<?php }?>