type; $entity = $taxonomy_data; // Use the taxonomy object itself as entity // Helper function to safely get array from $_GET function yatra_get_filter_array($key, $sanitize_callback = 'sanitize_text_field') { if (!isset($_GET[$key])) { return []; } $value = $_GET[$key]; // If it's already an array, sanitize each element if (is_array($value)) { return array_map($sanitize_callback, $value); } // If it's a string, convert to array and sanitize if (is_string($value) && !empty($value)) { // Handle comma-separated values $array = explode(',', $value); return array_map($sanitize_callback, array_filter($array)); } return []; } // Get active filters from URL parameters (same as main trip listing) $active_filters = [ 'destination' => sanitize_text_field($_GET['destination'] ?? ''), 'activity' => sanitize_text_field($_GET['activity'] ?? ''), 'price_min' => !empty($_GET['price_min']) ? intval($_GET['price_min']) : '', 'price_max' => !empty($_GET['price_max']) ? intval($_GET['price_max']) : '', 'trip_type' => sanitize_text_field($_GET['trip_type'] ?? ''), 'sort' => sanitize_text_field($_GET['sort'] ?? ''), 'difficulty' => yatra_get_filter_array('difficulty', 'intval'), 'rating' => yatra_get_filter_array('rating', 'intval'), 'categories' => yatra_get_filter_array('categories', 'intval'), 'destinations' => yatra_get_filter_array('destinations', 'intval'), 'activities' => yatra_get_filter_array('activities', 'intval'), 'accommodation' => yatra_get_filter_array('accommodation', 'sanitize_text_field'), 'included_services' => yatra_get_filter_array('included_services', 'sanitize_text_field'), 'special_offers' => yatra_get_filter_array('special_offers', 'sanitize_text_field'), 'booking_options' => yatra_get_filter_array('booking_options', 'sanitize_text_field'), 'age_suitability' => yatra_get_filter_array('age_suitability', 'sanitize_text_field'), ]; // Get type labels $type_labels = [ 'destination' => [ 'singular' => __('Destination', 'yatra'), 'plural' => __('Destinations', 'yatra'), /* translators: %s: destination name (e.g. "Nepal"). */ 'trips_title' => __('Trips in %s', 'yatra'), ], 'activity' => [ 'singular' => __('Activity', 'yatra'), 'plural' => __('Activities', 'yatra'), /* translators: %s: term name (activity or category, e.g. "Hiking" or "Adventure"). */ 'trips_title' => __('%s Trips', 'yatra'), ], 'category' => [ 'singular' => __('Category', 'yatra'), 'plural' => __('Categories', 'yatra'), /* translators: %s: term name (activity or category, e.g. "Hiking" or "Adventure"). */ 'trips_title' => __('%s Trips', 'yatra'), ], ]; $labels = $type_labels[$type] ?? $type_labels['category']; // Pagination: repository + handler totals; page size from WordPress Reading (posts per page) $trips = is_array($taxonomy_data->trips ?? null) ? $taxonomy_data->trips : []; $per_page = isset($taxonomy_data->trips_per_page) ? (int) $taxonomy_data->trips_per_page : yatra_get_posts_per_page(); $total_trips = isset($taxonomy_data->trips_total) ? (int) $taxonomy_data->trips_total : count($trips); $total_pages = isset($taxonomy_data->trips_pages) ? max(1, (int) $taxonomy_data->trips_pages) : ($total_trips > 0 ? (int) ceil($total_trips / max(1, $per_page)) : 1); $current_page = isset($taxonomy_data->trips_current_page) ? (int) $taxonomy_data->trips_current_page : yatra_get_archive_listing_paged(); $current_page = min(max(1, $current_page), $total_pages); $paged_trips = $trips; // Get entity image (no external hardcoded external URL) $entity_image = ''; // Prefer explicit featured_image or image when present if (!empty($taxonomy_data->featured_image)) { $entity_image = wp_get_attachment_url($taxonomy_data->featured_image); } elseif (!empty($taxonomy_data->image)) { $entity_image = $taxonomy_data->image; } // If still empty, try resolving from icon configuration (same logic as listing-destination.php) if (empty($entity_image) && !empty($taxonomy_data->icon)) { $icon = maybe_unserialize($taxonomy_data->icon); if (is_array($icon)) { $type = $icon['type'] ?? ''; $value = $icon['value'] ?? ''; if ($type === 'image' && !empty($value)) { if (is_numeric($value)) { $maybe_url = wp_get_attachment_image_url((int) $value, 'large'); if (!empty($maybe_url)) { $entity_image = $maybe_url; } } elseif (is_string($value) && filter_var($value, FILTER_VALIDATE_URL)) { $entity_image = $value; } } elseif (!empty($icon['url']) && filter_var($icon['url'], FILTER_VALIDATE_URL)) { // Legacy format: ['url' => 'https://...'] $entity_image = $icon['url']; } elseif (!empty($icon['id'])) { // Legacy format: ['id' => attachment_id] $maybe_url = wp_get_attachment_image_url((int) $icon['id'], 'large'); if (!empty($maybe_url)) { $entity_image = $maybe_url; } } } elseif (is_numeric($icon)) { $maybe_url = wp_get_attachment_image_url((int) $icon, 'large'); if (!empty($maybe_url)) { $entity_image = $maybe_url; } } elseif (is_string($icon) && filter_var($icon, FILTER_VALIDATE_URL)) { $entity_image = $icon; } } // Final internal placeholder fallback (no external Unsplash) if (empty($entity_image)) { $placeholder_src = plugins_url('assets/images/placeholder.png', dirname(__FILE__)); $entity_image = $placeholder_src; } yatra_get_header(); ?>
>

name); ?>

description)): ?>

description); ?>

name)); ?>

0) { echo sprintf( /* translators: 1: first item index on the page, 2: last item index on the page, 3: total trips, 4: current page number, 5: total page count. */ __('Showing %1$d-%2$d of %3$d trips (Page %4$d of %5$d)', 'yatra'), $start_item, $end_item, $total_trips, $current_page, $total_pages ); } else { echo esc_html__('No trips found', 'yatra'); } ?>

__('Recommended', 'yatra'), 'most_popular' => __('Most Popular', 'yatra'), 'price_low' => __('Price: Low to High', 'yatra'), 'price_high' => __('Price: High to Low', 'yatra'), 'rating_high' => __('Rating: Highest', 'yatra'), 'duration_short' => __('Duration: Shortest', 'yatra'), 'duration_long' => __('Duration: Longest', 'yatra'), ]; ?>

name)); ?>

1): ?>
= $current_page - $range && $i <= $current_page + $range)) : if ($i === $current_page) : ?> ... = $total_pages): ?>