Skip to content

Instantly share code, notes, and snippets.

@pgroot91
Created February 19, 2023 12:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pgroot91/deaf26fa7597a53e8ac66144982722eb to your computer and use it in GitHub Desktop.
Save pgroot91/deaf26fa7597a53e8ac66144982722eb to your computer and use it in GitHub Desktop.
lang
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment