Wordpress: include language variable in url Wordpress: include language variable in url wordpress wordpress

Wordpress: include language variable in url


A properly setup Wordpress 2.0+ will redirect all requests to /index.php so it won't need any htaccess updates, and your registered perma-struct looks fine. I think all that is left is configuring wordpress to use your %lang struct using a custom structure and you should be good to go


Try the following code

function custom_rewrite_rules(){  global $langs;    //Array containing locale => pretty permalink key value pair   /*    $langs = array (             'en_us' => 'en',            )   */  foreach($langs as $locale => $lang) {  add_rewrite_rule(                   '^'.$lang.'/\/(.*)/?$',                   'index.php?lang='.$locale,                   'top'                   );  }}add_action( 'init', 'custom_rewrite_rules' );


I've had problems with permalink structures too. Sometimes clicking the permalink you want, and save again solves the problem. As WordPress rewrites the htaccess when saving.