最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - get_locale() is different from $locale

programmeradmin2浏览0评论

for a language switcher I need to change the get_locale value to the needed language which works great using this code in my functions.php

add_filter( 'locale', 'set_my_locale' );
function set_my_locale( $lang ) {
    $lang= 'en_US';
    return $lang;
}

echo get_locale() results in en_US as needed, but $locale still shows the value defined in the wp-config.php? Using the code below did not help either:

function set_locale_frontend($locale)
{
    $lang= 'en_US';
    return $lang;
}
add_filter('locale', 'set_locale_frontend');

What am I doing wrong or am I missing to do? Please help! Thanks very much!

发布评论

评论列表(0)

  1. 暂无评论