default language by polylang plugin not working

For me it was the Polylang setting

Detect browser language (When the front page is visited, set the language according to the browser preference).

Found in wp-admin > languages > settings.

Test to uncheck that.


You can set default language by click on star in Polylang 'Languages' page, there will be a star for default language when someone is visiting your website. Also, don't forget to deactivate detect browser language in Polylang 'Settings' page, I hope this will work. This works fine for me.


this solution isn't standard! but work for me :)

replace (comment) this line in wp-content/plugins/polylang/frontend/choose-lang.php file (line 185)

$language = $this->options['hide_default'] && ( ( isset( $_SERVER['HTTP_REFERER'] ) && in_array( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ), $this->links_model->get_hosts() ) ) || ! $this->options['browser'] ) ?
        $this->model->get_language( $this->options['default_lang'] ) :
        $this->get_preferred_language();  // sets the language according to browser preference or default language

by

$language = 'fa';