Created
April 7, 2021 05:03
-
-
Save asifpix/5811de20d72e107e9f4718d60999a4b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
get_header(); | |
$getDestination = isset($_GET['tl_destination']) ? $_GET['tl_destination'] : ''; | |
$getTourType = isset($_GET['tl_type']) ? $_GET['tl_type'] : ''; | |
$getDuration = isset($_GET['tl_duration']) ? $_GET['tl_duration'] : ''; | |
$tax_query = array( | |
'relation' => 'OR', | |
array ( | |
'taxonomy' => 'destination', | |
'terms' => $getDestination, | |
'field' => 'slug', | |
'operator' => 'IN', | |
'include_children' => true, | |
), | |
array ( | |
'taxonomy' => 'tour_type', | |
'terms' => $getTourType, | |
'field' => 'slug', | |
'operator' => 'IN', | |
'include_children' => true, | |
), | |
array ( | |
'taxonomy' => 'duration', | |
'terms' => $getDuration, | |
'field' => 'slug', | |
'operator' => 'IN', | |
'include_children' => true, | |
) | |
); | |
function getTermList($termName){ | |
$terms = get_terms( array( | |
'taxonomy' => $termName, | |
'hide_empty' => false | |
) ); | |
foreach($terms as $term){ | |
$getTermValue[$term->slug] = $term->name; | |
// var_dump($term); | |
} | |
foreach($getTermValue as $key => $item){ | |
echo sprintf('<option value="%s">%s</option>', $key, $item); | |
} | |
} | |
$args = array( | |
'post_type' => 'travelux_tour', | |
'tax_query' => $tax_query, | |
'posts_per_page' = -1 | |
); | |
$query = new WP_Query($args); | |
if($query->have_posts()){ | |
} | |
?> | |
<div class="banner-section theme-banner"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-12"> | |
<div class="banner-content"> | |
<?php | |
$countString = (1 == $query->post_count) ? __('Tour found', 'travelux-core') : __('Tours found', 'travelux-core'); | |
echo sprintf('<h2>%d %s</h2>', $query->post_count, $countString); | |
?> | |
</div> | |
</div> | |
<!-- /.col --> | |
</div> | |
<!-- /.row --> | |
</div> | |
<!-- /.container --> | |
</div> | |
<!-- /.page-content-before --> | |
<div class="page-content page-content-padding"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-4 sidebar-area"> | |
<div class="advance-search-form-aside"> | |
<h3><?php echo __('Search Tour', 'travelux-core'); ?></h3> | |
<form action="<?php echo esc_url( home_url( '/' ) ) ?>" method="GET"> | |
<input type="hidden" name="tl_post_type" value="travelux_tour"> | |
<input type="hidden" name="tl_search" value="search"> | |
<div class="form-group"> | |
<select class="form-control" id="tl_destination" name="tl_destination"> | |
<option value="" disabled selected>Destination</option> | |
<?php getTermList('destination'); ?> | |
</select> | |
</div> | |
<div class="form-group"> | |
<select class="form-control" id="tl_type" name="tl_type"> | |
<option value="" disabled selected>Tour Type</option> | |
<?php getTermList('tour_type'); ?> | |
</select> | |
</div> | |
<div class="form-group"> | |
<select class="form-control" id="tl_duration" name="tl_duration"> | |
<option value="" disabled selected>Duration</option> | |
<?php getTermList('duration'); ?> | |
</select> | |
</div> | |
<button type="submit" class="btn btn-adv-search"><?php echo __('Find now', 'travelux-core') ?></button> | |
</form> | |
</div> | |
</div> | |
<div class="col-md-8 content-area"> | |
<div class="grid-view"> | |
<?php | |
while($query->have_posts()): | |
$query->the_post(); | |
?> | |
<div id="ft-card-<?php echo get_the_ID(); ?>" class="ft-card"> | |
<div class="ft-card__img"> | |
<?php the_post_thumbnail( 'travelux-tour-slide', array( 'class' => 'img-fluid' ) ); ?> | |
</div> | |
<div class="ft-card__content"> | |
<div class="ft-card__head"> | |
<?php $destination_name = get_the_terms(get_the_ID(), 'destination'); ?> | |
<p><?php echo esc_html($destination_name[0]->name);?></p> | |
<h4><a href="<?php echo get_the_permalink(); ?>"><?php echo get_the_title(); ?></a></h4> | |
<div class="ft-card__rating"> | |
<?php | |
//display star rating | |
$rating = get_post_meta(get_the_ID(), 'tl_tour_rating', true); | |
$html = ''; | |
$html .= '<div class="ft-card__star"><div class="display-star-rating">'; | |
for ($i = 0; $i < 5; $i++) { | |
$checked = ''; | |
if ($rating > 0) { | |
$checked = ($i < $rating) ? 'checked' : ''; | |
} | |
$html .= '<i class="fas fa-star ' . esc_attr($checked) . ' "></i>'; | |
} | |
$html .= '</div></div>'; | |
printf($html); | |
//display review count | |
$likeData = '"xs_post_id":"' . get_the_ID() . '"'; | |
$reviewArguments = array( | |
'post_type' => 'xs_review', | |
'meta_query' => array( | |
array( | |
'key' => 'xs_public_review_data', | |
'value' => '' . $likeData . '', | |
'compare' => 'LIKE', | |
), | |
), | |
); | |
$review_data = new \WP_Query($reviewArguments); | |
$totalReviews = isset($review_data->post_count) ? $review_data->post_count : 0; | |
$review_text = ($totalReviews == 1) ? __('Review', 'travelux') : __('Reviews', 'travelux'); | |
printf('<div class="ft-card__review">%d %s</div>', esc_html($totalReviews), esc_html($review_text)); | |
?> | |
</div> | |
<div class="ft-card__excerpt"> | |
<p><?php echo get_the_excerpt(); ?></p> | |
</div> | |
</div> | |
<div class="ft-card__bottom"> | |
<div class="ft-card__details hidden-in-grid"> | |
<a href="<?php echo get_the_permalink(); ?>" class="btn btn-details btn-block"><?php echo __('Details', 'travelux-core'); ?></a> | |
</div> | |
<div class="ft-card__left"> | |
<?php $durationTerm = get_the_terms(get_the_ID(), 'duration'); | |
$duration = ($durationTerm) ? $durationTerm[0]->name : __('Duration not defined', 'travelux-core'); | |
$get_age_limit = get_post_meta(get_the_ID(), 'tl_tour_age_restrictions', true); | |
$age = ('' != $get_age_limit) ? $get_age_limit : __('Age limit not defined', 'travelux-core'); | |
printf('<p>%s</p>', $duration); | |
printf('<p>%s</p>', $age); | |
?> | |
</div> | |
<div class="ft-card__right"> | |
<?php do_action( 'single_tour_price' ); ?> | |
</div> | |
</div> | |
<div class="ft-card__details hidden-in-list"> | |
<a href="<?php echo get_the_permalink(); ?>" class="btn btn-details btn-block"><?php echo __('Details', 'travelux-core'); ?></a> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; | |
wp_reset_postdata(); | |
?> | |
</div> | |
<!-- pagination start --> | |
<!-- <div class="pagination-wrap"> | |
<a class="prev page-numbers" href="#"><i class="fas fa-angle-left"></i></a> | |
<span aria-current="page" class="page-numbers current">1</span> | |
<a class="page-numbers" href="#">2</a> | |
<a class="page-numbers" href="#">3</a> | |
<a class="page-numbers" href="#">4</a> | |
<a class="page-numbers" href="#">5</a> | |
<a class="next page-numbers" href="#"><i class="fas fa-angle-right"></i></a> | |
</div> --> | |
<!-- pagination end --> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- /.page-content --> | |
<?php | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment