I spent last 4 hours searching for an answer how to change html lang=”bg-BG” to html lang=”en-GB”. I already reviewed the old topics, and it seems that define (‘WPLANG’, ‘xx_XX’); is not working anymore, after WordPress v4 release.

The web site has multiple pages and post written in bg-BG, but now the client needs just a single en-GB page to present his services. The page is already prepared for the public, but I want to change the html lang to the correct language. I already managed to change the og to be

<meta property="og:locale" content="en_GB"/>

with this

add_filter('wpseo_locale', 'override_og_locale');
function override_og_locale($locale)

{
    if ( is_page( 2846) ) {
        return "en_GB";

    }
    else {
        return "bg_BG";
    }
}

Does anyone have an idea what php function do I need? I think it will be an overkill to use a plugin just for a single page…

1 Answer
1

You should hook with the locale filter:

add_filter('locale', 'my_get_locale');

function my_get_locale($locale) {

    if ( is_page( 2846) ) {

        return "en_GB";

    }

    return $locale;
}   

Leave a Reply

Your email address will not be published. Required fields are marked *