function itinerary_shortcode_output($is_ajax = false) { $output = ''; if (!$is_ajax && empty($_POST)) { return '
Start by chatting with Appie to generate your itinerary!
'; } $selected_location = sanitize_text_field($_POST['location'] ?? ''); $selected_interest = array_map('sanitize_text_field', (array) ($_POST['interest_type'] ?? [])); $selected_days = absint($_POST['days'] ?? 0); if (empty($selected_location) || empty($selected_interest) || $selected_days < 1) { return '
Please complete all required fields to generate your itinerary.
'; } $location_term = get_term_by('slug', $selected_location, 'location'); if (!$location_term) { return '
Invalid location selected. Please try again.
'; } $output .= '
'; $output .= '

Your Personalized Itinerary

'; $output .= '

Explore ' . esc_html($location_term->name) . ' based on your interests and time.

'; $shown_ids = []; for ($day = 1; $day <= $selected_days; $day++) { $output .= '

Day ' . $day . '

'; $output .= '
'; $args_first_spot = [ 'post_type' => 'travel_spot', 'posts_per_page' => 1, 'orderby' => 'meta_value_num', 'meta_key' => 'popularity', 'order' => 'DESC', 'post__not_in' => $shown_ids, 'meta_query' => [ 'relation' => 'OR', [ 'key' => 'exclude_from_daywise', 'compare' => 'NOT EXISTS' ], [ 'key' => 'exclude_from_daywise', 'value' => '0', 'compare' => '=' ] ], 'tax_query' => [ 'relation' => 'AND', [ 'taxonomy' => 'location', 'field' => 'slug', 'terms' => [$selected_location], ], [ 'taxonomy' => 'interest_type', 'field' => 'slug', 'terms' => $selected_interest, 'operator' => 'IN' ] ] ]; $query_first_spot = new WP_Query($args_first_spot); if ($query_first_spot->have_posts()) { while ($query_first_spot->have_posts()) { $query_first_spot->the_post(); $shown_ids[] = get_the_ID(); $output .= '

' . get_the_title() . '

'; $visiting_hours = get_field('visiting_duration', get_the_ID()); if ($visiting_hours) { $output .= '
' . esc_html($visiting_hours) . ' Hours
'; } if (has_post_thumbnail()) { $output .= '
' . get_the_post_thumbnail(get_the_ID(), 'full') . '
'; } $output .= '
' . apply_filters('the_content', get_the_content()) . '
'; $output .= '
'; $related_spots = get_field('nearby', get_the_ID()); if ($related_spots) { foreach ($related_spots as $related_spot) { if (!in_array($related_spot->ID, $shown_ids)) { $shown_ids[] = $related_spot->ID; $output .= '

' . get_the_title($related_spot->ID) . '

'; $related_visiting_hours = get_field('visiting_duration', $related_spot->ID); if ($related_visiting_hours) { $output .= '
' . esc_html($related_visiting_hours) . ' Hours
'; } if (has_post_thumbnail($related_spot->ID)) { $output .= '
' . get_the_post_thumbnail($related_spot->ID, 'full') . '
'; } $related_post_content = get_post_field('post_content', $related_spot->ID); $output .= '
' . apply_filters('the_content', $related_post_content) . '
'; $output .= '
'; } } } } wp_reset_postdata(); } } $suggested_args = [ 'post_type' => 'travel_spot', 'posts_per_page' => -1, 'orderby' => 'meta_value_num', 'meta_key' => 'popularity', 'post__not_in' => $shown_ids, 'meta_query' => [ [ 'key' => 'exclude_from_daywise', 'value' => '1', 'compare' => '=' ] ], 'tax_query' => [ ['taxonomy' => 'location', 'field' => 'slug', 'terms' => $selected_location], ['taxonomy' => 'interest_type', 'field' => 'slug', 'terms' => $selected_interest] ] ]; $suggested_query = new WP_Query($suggested_args); if ($suggested_query->have_posts()) { $output .= '

Other Popular Things To Do As Per Your Interest

'; $output .= '
'; $output .= '
'; while ($suggested_query->have_posts()) { $suggested_query->the_post(); $output .= '

' . get_the_title() . '

'; if (has_post_thumbnail()) { $output .= '
' . get_the_post_thumbnail(get_the_ID(), 'full') . '
'; } $output .= '
' . apply_filters('the_content', get_the_content()) . '
'; } $output .= '
'; wp_reset_postdata(); } $output .= '
'; // Close .itinerary-wrapper $output .= << .itinerary-wrapper { background: #f9f9f9; padding: 2rem; border-radius: 1rem; font-family: sans-serif; } .itinerary-title { font-size: 1.75rem; margin-bottom: 0.5rem; color: #2c3e50; } .itinerary-subtitle { color: #555; margin-bottom: 1.5rem; } .itinerary-day { margin-bottom: 2rem; padding: 1rem; background: #ffffff; border-radius: 0.75rem; box-shadow: 0 0 6px rgba(0,0,0,0.05); } .itinerary-day h3 { font-size: 1.25rem; margin-bottom: 0.5rem; } .recommendations-grid { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; } .recommendation-item { flex: 1 1 45%; background: #f1f5f9; padding: 0.75rem; border-radius: 0.5rem; text-align: center; } .recommendation-thumb img { max-width: 100%; height: auto; border-radius: 0.5rem; } .transport-section { margin-top: 2rem; padding: 1rem; background: #eef2f7; border-radius: 0.75rem; } CSS; return $output; }
Warning: Cannot modify header information - headers already sent by (output started at /home2/xdykocmy/public_html/website_b6129743/wp-content/themes/tripp/inc/itinerary/itinerary-shortcode.php:1) in /home2/xdykocmy/public_html/website_b6129743/wp-includes/pluggable.php on line 1450

Warning: Cannot modify header information - headers already sent by (output started at /home2/xdykocmy/public_html/website_b6129743/wp-content/themes/tripp/inc/itinerary/itinerary-shortcode.php:1) in /home2/xdykocmy/public_html/website_b6129743/wp-includes/pluggable.php on line 1453