Skip to content

Instantly share code, notes, and snippets.

@guydumais
Last active July 22, 2017 06:52
Show Gist options
  • Save guydumais/9a25917a905b68969044c6a046328aac to your computer and use it in GitHub Desktop.
Save guydumais/9a25917a905b68969044c6a046328aac to your computer and use it in GitHub Desktop.
WordPress ➧ Changer le code de langue WordPress dynamiquement
/**
* Changer le code de langue WordPress dynamiquement.
*
* @author Guy Dumais.
* @link https://guydumais.digital/changer-le-code-de-langue-wordpress-dynamiquement/
*/
// Filtrer les attributs de langue dans la balise html.
add_filter( 'language_attributes', $af = function( $output, $doctype ) {
if ( strpos($output, 'fr-FR') !== false ) {
$output = str_replace('fr-FR', 'fr-CA', $output);
}
return $output;
}, 10, 2 );
unset( $af );
// Filtrer les attributs de langue des balises og.
add_filter( 'locale', $af = function( $locale ) {
if( 'fr_FR' == $locale ) {
$locale = 'fr_CA';
}
return $locale;
}, 10 );
unset( $af );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment