Change WordPress language in functions.php
742
I want to change the wordpress language in functions.php. WordPress change language
I tried with the below code.
function myprefix_live_site_locale( $locale ) {
if ( ! is_admin() ) {
if (strpos($_SERVER['REQUEST_URI'], '/ar/') !== false) {
return 'ar';
} else {
return 'tr_TR';
}
}
return $locale;
}
add_filter( 'locale', 'myprefix_live_site_locale' );
Answer
Solution:
I have checked your script, it looks Okay. There are few changes need to change:
Change
strpos($_SERVER['REQUEST_URI'], '/ar/')
tostrpos($_SERVER['REQUEST_URI'], '/ar')
and
return 'ar'
toreturn 'ar_ar'
.