简体   繁体   English

更改 yoast SEO 插件设置的 Wordpress 语言环境

[英]Changing Wordpress locale as set by yoast SEO plugin

My WordPress site is based in Great Britain.我的 WordPress 网站位于英国。 I was able to change the html lang -attribute from en-US to en-GB , however when I view my source code the og:locale attribute of open graph displays as en-US , it is generated by yoast SEO plugin.我能够将 html lang -attribute 从en-US更改为en-GB ,但是当我查看我的源代码时,开放图的og:locale属性显示为en-US ,它是由 yoast SEO 插件生成的。 Is there a way to change locale to en-GB ?有没有办法将语言环境更改为en-GB

From the documentation :文档

wpseo_locale (string)

Allows changing the locale used in the opengraph set (and possibly in other locations later on).允许更改 opengraph 集中使用的区域设置(以及稍后可能在其他位置)。

Here's a specific example of how someone else solved it in functions.php:这是其他人如何在functions.php中解决它的具体示例

add_filter('wpseo_locale', 'override_og_locale');
function override_og_locale($locale)
{
    return "en_GB";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM