I'm trying to avoid installing a full blown multi-language plugin on my site, and I'm nearly there.

Just one thing, I need to control whether this plugin – WP-Members – are getting translated or not on a per page basis.

Default language is Norwegian, and all pages that are children of /en/ are automatically being set to English (using this method). The plugin are using .po/.mo-files, but changing the html-code doesn't make the plugin change its language.

Is it possible to somehow trick the plugin to think the blog is in another language?

1 Answer 1


Yes, sort of. Any localized plugin such as WP-Members runs off of the "locale" that WordPress is set to. This value can be filtered for WP as a whole using the locale filter. But it can also be filtered for plugins using plugin_locale

See: https://developer.wordpress.org/reference/hooks/plugin_locale/

To use plugin_locale specific to the text domain for the plugin* (which in this case is 'wp-members')

add_filter( 'plugin_locale', 'my_plugin_locale_filter', 10, 2 );
function my_plugin_locale_filter( $locale, $domain ) {

    // If the text domain is 'wp-members'
    if ( 'wp-members' == $domain ) {
         * This logic adapted from the method you referenced at
         * http://beta.beantin.se/wordpress-setting-language-individual-pages/
         * Note that the function get_top_parent_page_id() from that example
         * is used here, and the logic is not adapted to your specific 
         * question (i.e. I assume the default $postLanguage value is
         * Norwegian in your case and you are switching it to English) so 
         * change this to match what you are doing with the other elements
         * being used from that process.
        $postLanguage = "en-GB";
        if (is_page()) {
                $svPageID = get_top_parent_page_id(); // ID of parent page
                if ($svPageID == "565") { // ID of the "på svenska" page
                    $postLanguage = "sv";    
            $locale = $postLanguage;

    // Always return the value being filtered.
    return $locale;

*The text domain for any plugin should be noted in the header of the plugin's main file. For example, if you open wp-members.php and look at the plugin header, you will find this listed under the heading "Text Domain:".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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