Changing the language of a single page

I have a wordpress site in a language that aligns RTL, but some pages are in English. These pages look terrible, however, because the English text is aligned with the RTL language, and punctuation, etc. appear on the wrong the side.

How can I set the language for a single page or several individual pages?

4 s
4

The locale filter that allows you to set the locale specifically. You can check the current page, and alter the value based on that.

add_filter('locale', 'change_my_locale');
function change_my_locale( $locale ) {
    if ( is_page('slug-here') ) {
        return 'en_US';
    }
    return $locale;
}

Leave a Comment