| @@ -77,9 +77,16 @@ | ||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $taxonomy_data->trips = $tripsWithReviews; |
| 80 | 80 | |
| 81 | - $this->prevent404(); | |
| 81 | + // Configure $wp_query + virtual WP_Post so FSE block themes resolve an archive | |
| 82 | + // template (not 404.html) for taxonomy pages. | |
| 83 | + $this->setupPageEnvironment('archive', [ | |
| 84 | + 'title' => (string) ($taxonomy_data->name ?? $taxonomy_data->title ?? $slug), | |
| 85 | + 'object_id' => (int) ($taxonomy_data->id ?? 0), | |
| 86 | + 'post_type' => 'page', | |
| 87 | + 'post_name' => $slug, | |
| 88 | + ]); | |
| 82 | 89 | |
| 83 | 90 | $this->setGlobal('yatra_taxonomy_data', $taxonomy_data); |
| 84 | 91 | |
| 85 | 92 | $this->setQueryVars([ |
| @@ -88,19 +95,9 @@ | ||
| 88 | 95 | 'yatra_taxonomy' => $taxonomy_data, |
| 89 | 96 | 'yatra_page' => $base, |
| 90 | 97 | ]); |
| 91 | 98 | |
| 92 | - $template_path = YATRA_PLUGIN_PATH . 'templates/single-taxonomy.php'; | |
| 93 | - | |
| 94 | - if (!file_exists($template_path)) { | |
| 95 | - $this->logError("Taxonomy template not found: {$template_path}"); | |
| 96 | - return false; | |
| 97 | - } | |
| 98 | - | |
| 99 | - include $template_path; | |
| 100 | - $this->exit(); | |
| 101 | - | |
| 102 | - return true; | |
| 99 | + return $this->selectTemplate('single-taxonomy', null, 'taxonomy-' . $taxonomy_type); | |
| 103 | 100 | } |
| 104 | 101 | |
| 105 | 102 | /** |
| 106 | 103 | * Get taxonomy data by type and slug |