'experience_journey',
'posts_per_page' => -1,
));
// Pridobi uporabniško določen vrstni red journeyev
$order = get_option('experience_journey_order', '');
$order_array = !empty($order) ? explode(',', $order) : array();
// Če imamo vrstni red, sortiraj journeye po njem
if (!empty($order_array)) {
$position_map = array_flip($order_array);
usort($journeys, function($a, $b) use ($position_map) {
$pos_a = isset($position_map[$a->ID]) ? $position_map[$a->ID] : PHP_INT_MAX;
$pos_b = isset($position_map[$b->ID]) ? $position_map[$b->ID] : PHP_INT_MAX;
return $pos_a - $pos_b;
});
}
// Za vsak journey prikaži njegove ture
foreach ($journeys as $journey) {
// Pridobi naslov journeya
$journey_title = get_post_meta($journey->ID, '_page_title', true);
if (!$journey_title) {
$journey_title = $journey->post_title;
}
// Pridobi ture za ta journey
$saved_order = get_option('individual_tour_order_' . $journey->ID, '');
$tour_order_array = !empty($saved_order) ? explode(',', $saved_order) : array();
$args = array(
'post_type' => 'individual_tour',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_experience_journey',
'value' => $journey->ID,
'compare' => '='
)
)
);
// Če imamo shranjen vrstni red tur, uporabi ga
if (!empty($tour_order_array)) {
$args['post__in'] = $tour_order_array;
$args['orderby'] = 'post__in';
}
$tours = new WP_Query($args);
// Če ima journey ture, prikaži naslov in ture
if ($tours->have_posts()) :
?>
have_posts()) : $tours->the_post();
// Pridobi hero sliko
$hero_image_id = get_post_meta(get_the_ID(), '_hero_image', true);
$image = wp_get_attachment_image_url($hero_image_id, 'full');
// Če hero slika ne obstaja, uporabi featured image
if (!$image) {
$image = get_the_post_thumbnail_url(get_the_ID(), 'large');
}
// Če ni nobene slike, uporabi placeholder
if (!$image) {
$image = get_theme_file_uri('images/placeholder.jpg');
}
$price = get_post_meta(get_the_ID(), '_tour_price', true);
$duration = get_post_meta(get_the_ID(), '_tour_duration', true);
?>