admin管理员组文章数量:1125907
I have noticed that in the <html>
tag on my WP site that the language is defined as US English.
<html lang="en-US" prefix="og: ">
I would like to change it to British English en-GB
but I'm not sure of the best way.
I dug around and found language_attributes()
in general-template.php
which makes a call to get_bloginfo('language')
. I could manually insert the value here but that doesn't seem like the best way to do it.
What is the proper way to change this value?
I have noticed that in the <html>
tag on my WP site that the language is defined as US English.
<html lang="en-US" prefix="og: http://ogp.me/ns#">
I would like to change it to British English en-GB
but I'm not sure of the best way.
I dug around and found language_attributes()
in general-template.php
which makes a call to get_bloginfo('language')
. I could manually insert the value here but that doesn't seem like the best way to do it.
What is the proper way to change this value?
Share Improve this question edited Mar 26, 2024 at 1:37 Jesse Nickles 7357 silver badges19 bronze badges asked Oct 20, 2013 at 17:54 Scott HelmeScott Helme 2711 gold badge2 silver badges9 bronze badges2 Answers
Reset to default 13The value for that string is normally taken from the option WPLANG
in your database table $prefix_options
. You can set it in the backend under Settings/General (wp-admin/options-general.php
) or per SQL.
There several ways to change that value per PHP:
Create a global variable
$locale
in yourwp-config.php
:$locale = 'en_GB';
Declare the constant
WPLANG
in yourwp-config.php
:define( 'WPLANG', 'en_GB' );
This has been deprecated, but it'll still work.
Filter
locale
:add_filter( 'locale', function() { return 'en_GB'; });
This a very flexible way, because you can add more conditions to that function, for example check the current site ID in a multisite.
As for recent version of WordPress 4+ the solution provided here is deprecated, please check my answer here for more details
https://stackoverflow.com/a/37571439/1358670
本文标签:
版权声明:本文标题:localization - How to change the lang="en-US" value of the HTML document? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736603516a1945273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论