/** * Add hreflang tags for GTranslate subdomain languages * ExploreTraveler.com */ add_action( 'wp_head', 'exploretraveler_add_hreflang_tags', 1 ); function exploretraveler_add_hreflang_tags() { // Get the current path (without domain) $path = $_SERVER['REQUEST_URI']; // Clean the path (remove query strings if any) $path = strtok( $path, '?' ); // List of your languages (subdomain => hreflang code) $languages = array( 'en' => 'https://exploretraveler.com', // English (main) 'es' => 'https://es.exploretraveler.com', // Spanish 'ar' => 'https://ar.exploretraveler.com', // Arabic 'zh-CN' => 'https://zh-CN.exploretraveler.com', // Chinese Simplified 'zh-TW' => 'https://zh-TW.exploretraveler.com', // Chinese Traditional 'fr' => 'https://fr.exploretraveler.com', // French 'de' => 'https://de.exploretraveler.com', // German 'id' => 'https://id.exploretraveler.com', // Indonesian 'ja' => 'https://ja.exploretraveler.com', // Japanese 'ko' => 'https://ko.exploretraveler.com', // Korean 'ms' => 'https://ms.exploretraveler.com', // Malay 'ru' => 'https://ru.exploretraveler.com', // Russian 'uk' => 'https://uk.exploretraveler.com', // Ukrainian 'tl' => 'https://tl.exploretraveler.com', // Filipino ); // Output the tags foreach ( $languages as $code => $domain ) { $url = rtrim( $domain, '/' ) . $path; echo '' . "\n"; } // x-default points to the English version $default_url = 'https://exploretraveler.com' . $path; echo '' . "\n"; }
Skip to content

Driving in Hsinchu Taiwan