您可以尝试使用cookie。如果这是访客的第一次,设置一个cookie。让用户在单击所需语言后设置cookie。
你可以参考他的样品Wordpress Redirect based on the prescence of a cookie
你可以稍微调整一下
if ( !isset($_COOKIE["language"])) {
if(!isset($_GET["language"])){ // Check if user has set a language through a get function
setcookie(\'language\', 1, time()+1209600, "/", "http://www,yourdomain.com/".$_GET[\'language\']."", false); // Set the chosen cookie
wp_redirect( get_site_url().\'/\'.$_GET[\'language\'] ); exit; // redirect to the chosen language
}else{
setcookie(\'language\', 1, time()+1209600, "/", "http://www,yourdomain.com/en", false); // If did not choose, just redirect to your default language
}
}else{
wp_redirect( get_site_url().\'/\'.$_COOKIE[\'language\'] ); exit; // Else, redirect to the language based on the cookie stored previously
}