How to override Yoast’s Open Graph tag for locale in WordPress

How to override Yoast’s Open Graph tag for locale in WordPress

Yoast’s SEO plugin for WordPress is awesome – easy to install and set up, powerful once you know how to work the more advanced features. However we commonly have to fix one little thing that doesn’t seem currently editable within Yoast itself.

That is the Open Graph locale tag, which is set to en_US by default:

Wordpress Yoast with incorrect locale tag

Now, in order to fix this we’re going to have to get our hands a little dirty by editing our themes functions.php file. Go to Appearance, then Editor and click on functions.php.

At the bottom, before the closing php tag, add the following function:

add_filter('wpseo_locale', 'override_og_locale');

function override_og_locale($locale)


return "en_GB";


Like so:

fixing incorrect Wordpress Yoast open graph locale tag

E voila! The offending tag is now set to en_GB. You may also notice we’ve removed that function that autocorrects ‘Wordpress’ to ‘WordPress’…. well, we found it a little annoying that it was altering text for us!

Good luck with your changes – are there any other frustrating little problems with WordPress you’d like us to cover? Let us know in the comments!


Image credit: by Betty Longbottom:

Author Owen Radford

More posts by Owen Radford