0

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...

  • See filter 'language_attributes' in get_language_attributes() function in "../../../wp-includes/general-template.php". – bonger Jan 25 '16 at 19:19
2

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;
}   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.