feat: city guide on city pages (tagline, facts, About, seasons)

Editable per city under Viator tours > Destinations. Shown above the
tours on page 1 of an unfiltered listing only; filtering and paging jump
to the results. Text recovered from the six old /tour-destination/ pages
is imported once into empty guides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 09:58:54 +03:30
parent 466ea0ac5f
commit 2ded000a27
12 changed files with 846 additions and 10 deletions

View File

@@ -7,11 +7,16 @@
* submits via GET. VC_Display::filter_archive_query() reads the same state.
*
* Args: $vc_title, $vc_subtitle, $vc_query, $vc_form_action, $vc_after_hero
* (HTML printed between the hero and the results, e.g. the region city grid).
* (HTML printed between the hero and the results, e.g. the region city grid),
* $vc_tagline (line under the title), $vc_list_heading (heading above the
* results) and $vc_jump (true: filtering and paging land on the results).
*/
defined( 'ABSPATH' ) || exit;
$vc_after_hero = isset( $vc_after_hero ) ? (string) $vc_after_hero : '';
$vc_after_hero = isset( $vc_after_hero ) ? (string) $vc_after_hero : '';
$vc_tagline = isset( $vc_tagline ) ? (string) $vc_tagline : '';
$vc_list_heading = isset( $vc_list_heading ) ? (string) $vc_list_heading : '';
$vc_anchor = empty( $vc_jump ) ? '' : '#tour-list';
$f = VC_Display::get_filter_state();
@@ -53,9 +58,7 @@ $vc_dur_labels = array(
);
// Whether any filter is active (drives the "Clear filters" control).
$vc_active = ( '' !== $f['q'] || ! empty( $f['dest'] ) || ! empty( $f['cat'] ) || ! empty( $f['dur'] )
|| $f['pmin'] > 0 || $f['pmax'] < 1000 || $f['rating'] > 0
|| $f['freecancel'] || $f['bestdeal'] || $f['sellout'] );
$vc_active = VC_Display::filters_active( $f );
// Current filters as a base URL, so pagination links keep the query string.
$vc_base_args = array();
@@ -70,12 +73,12 @@ if ( $f['bestdeal'] ) { $vc_base_args['bestdeal'] = 1; }
if ( $f['sellout'] ) { $vc_base_args['sellout'] = 1; }
if ( 'newest' !== $f['sort'] ) { $vc_base_args['sort'] = $f['sort']; }
$vc_page_url = function ( $n ) use ( $vc_action, $vc_base_args ) {
$vc_page_url = function ( $n ) use ( $vc_action, $vc_base_args, $vc_anchor ) {
$args = $vc_base_args;
if ( $n > 1 ) {
$args['paged'] = $n;
}
return empty( $args ) ? $vc_action : add_query_arg( $args, $vc_action );
return ( empty( $args ) ? $vc_action : add_query_arg( $args, $vc_action ) ) . $vc_anchor;
};
$vc_hero_img = vc_hero_image_source();
@@ -94,8 +97,11 @@ $vc_hero_img = vc_hero_image_source();
echo vc_breadcrumb_html( vc_breadcrumb_trail(), $vc_crumb_current ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<h1 class="hero__title"><?php echo esc_html( $vc_title ); ?></h1>
<?php if ( '' !== $vc_tagline ) : ?>
<p class="hero__tagline"><?php echo esc_html( $vc_tagline ); ?></p>
<?php endif; ?>
<form class="filters" id="vc-filter-form" method="get" action="<?php echo esc_url( $vc_action ); ?>" novalidate>
<form class="filters" id="vc-filter-form" method="get" action="<?php echo esc_url( $vc_action . $vc_anchor ); ?>" novalidate>
<div class="filters__row">
<div class="fsearch">
<?php echo vc_icon( 'search', 'fsearch__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
@@ -191,6 +197,10 @@ $vc_hero_img = vc_hero_image_source();
<section class="section" id="tour-list">
<div class="container">
<?php if ( '' !== $vc_list_heading ) : ?>
<p class="pill cty-eyebrow"><?php echo esc_html__( 'Tours', 'viator-collector' ); ?></p>
<h2 class="cty-h2 cty-tours-h"><?php echo esc_html( $vc_list_heading ); ?></h2>
<?php endif; ?>
<div class="results">
<p class="results__count" role="status">
<?php if ( $vc_total ) : ?>

View File

@@ -9,6 +9,17 @@ get_header();
$vc_term = get_queried_object();
$vc_name = ( $vc_term && ! is_wp_error( $vc_term ) ) ? $vc_term->name : __( 'Tours', 'viator-collector' );
$vc_desc = term_description();
// City guide (destinations only): tagline in the banner; facts, About and
// Seasons above the tours on page 1 of an unfiltered listing.
$vc_guide = '';
$vc_tagline = '';
if ( is_tax( 'viator_destination' ) && $vc_term && ! is_wp_error( $vc_term ) ) {
$vc_tagline = VC_City_Guide::tagline( $vc_term );
if ( VC_City_Guide::is_visible_here() ) {
$vc_guide = VC_City_Guide::render( $vc_term );
}
}
?>
<main class="vc-app vc-listing vc-listing--term">
<?php
@@ -24,6 +35,11 @@ $vc_desc = term_description();
'url' => get_post_type_archive_link( 'viator_tour' ),
),
),
'vc_tagline' => $vc_tagline,
'vc_after_hero' => $vc_guide,
/* translators: %s: city name. */
'vc_list_heading' => $vc_guide ? sprintf( __( 'Things to do in %s', 'viator-collector' ), $vc_name ) : '',
'vc_jump' => '' !== $vc_guide,
)
);
?>