i have a wordpress blog in 2 languages. by default, i have: <meta http-equiv="Content-Language" content="ES"> but i would like to have in some pages that are in English "EN" this meta tag changed. all posts that are in english are in a subfolder "url/en/post.html" how can i make with php that if the url has "url/en" it sends the word "EN" ?
I have no idea how your server is set up, so this will most likely be inefficient code (is there actually a folder called 'en' or is that a mod_rewrite url?). $lang = "es" //set a default here, in case the script fails for whatever reason. if(preg_match("/\/en\//",$_SERVER['REQUEST_URI'])) { // will only match 'en' if it is preceeded and followed by one forward slash $lang = "en"; } elseif(preg_match("/\/es\//",$_SERVER['REQUEST_URI'])) { $lang = "es"; } ?> <meta http-equiv="Content-Language" content="<?php echo $lang ?>">
thanks !! i made some modifications and it works ! here is the one i used: <?php {$lang = "es, us";} //set a default here, in case the script fails for whatever reason. if(preg_match("/\/en\//",$_SERVER['REQUEST_URI'])) { $lang = "en, us"; //if the post has in the url /en/ show this. } ?> <meta http-equiv="Content-Language" content="<?php echo $lang ?>"> this could be useful for blogs and sites in multiple languages. thanks for your help ntomsheck.