SEO local, perdidos/encontrados y solicitud de cita
- Datos estructurados schema.org AnimalShelter en la portada (dirección, horario para Google configurable, teléfono, redes, idiomas). - Preguntas frecuentes: animales perdidos o encontrados, con el buscador oficial de Euskadi. - Formulario: motivo «Pedir cita para una visita» con día y hora preferidos. - Migración 6: actualiza las preguntas frecuentes si no se han editado. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
50
wp-content/mu-plugins/gure-ametsa/seo.php
Normal file
50
wp-content/mu-plugins/gure-ametsa/seo.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* SEO local: datos estructurados schema.org de la protectora (AnimalShelter) en la portada.
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/** Dirección estructurada a partir de «Calle, nº · CP Localidad (Provincia)». */
|
||||
function ga_postal_address() {
|
||||
$raw = (string) ga_info( 'direccion' );
|
||||
$address = array( '@type' => 'PostalAddress', 'addressCountry' => 'ES' );
|
||||
if ( preg_match( '/^(.+?)\s*·\s*(\d{5})\s+(.+?)(?:\s*\((.+)\))?$/u', $raw, $m ) ) {
|
||||
$address += array_filter( array(
|
||||
'streetAddress' => trim( $m[1] ),
|
||||
'postalCode' => $m[2],
|
||||
'addressLocality' => trim( $m[3] ),
|
||||
'addressRegion' => $m[4] ?? '',
|
||||
) );
|
||||
} else {
|
||||
$address['streetAddress'] = $raw;
|
||||
}
|
||||
return $address;
|
||||
}
|
||||
|
||||
add_action( 'wp_head', function () {
|
||||
if ( ! is_front_page() ) {
|
||||
return;
|
||||
}
|
||||
$hours = array_filter( array_map( 'trim', explode( ',', (string) ga_setting( 'contact', 'hours_schema', 'Mo-Fr 10:00-13:00, Mo-Fr 14:00-19:00' ) ) ) );
|
||||
$data = array_filter( array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'AnimalShelter',
|
||||
'@id' => home_url( '/#protectora' ),
|
||||
'name' => 'Bilagun · Gure Ametsa Bi Lagun',
|
||||
'alternateName'=> array( 'Bilagun', 'Gure Ametsa Bi Lagun' ),
|
||||
'url' => home_url( '/' ),
|
||||
'logo' => content_url( 'mu-plugins/gure-ametsa/assets/logo-mark.png' ),
|
||||
'image' => content_url( 'mu-plugins/gure-ametsa/assets/logo-mark.png' ),
|
||||
'description' => get_bloginfo( 'description' ),
|
||||
'telephone' => ga_info( 'telefono' ) ? '+34 ' . ga_info( 'telefono' ) : '',
|
||||
'email' => ga_info( 'email' ),
|
||||
'address' => ga_postal_address(),
|
||||
'openingHours' => $hours,
|
||||
'hasMap' => ga_info( 'maps' ),
|
||||
'areaServed' => array( 'Hondarribia', 'Irun' ),
|
||||
'sameAs' => array_values( array_filter( array( ga_info( 'instagram' ), ga_info( 'facebook' ), ga_info( 'tiktok' ), ga_info( 'youtube' ) ) ) ),
|
||||
'knowsLanguage'=> array( 'es', 'eu' ),
|
||||
) );
|
||||
echo '<script type="application/ld+json">' . wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) . "</script>\n";
|
||||
}, 20 );
|
||||
Reference in New Issue
Block a user