Overview of the Issue
If you are using the Use directory for default language option and you add a Language Switcher Block on the root page, it erroneously points to the default language without the directory. (i.e '/' instead of '/en’).
This issue prevents users from selecting the default language on these specific pages.
Workaround
This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-model-build.php file.
- Look for line 64.
- Change:
public function get( $slot, $template_data = [] ) { $vars = []; $vars['current_language_code'] = $this->sitepress->get_current_language(); $vars['languages'] = $this->get_language_items( $slot, $template_data ); $vars['css_classes'] = $this->get_slot_css_classes( $slot ); $vars['css_classes_link'] = self::LINK_CSS_CLASS; $vars = $this->add_backward_compatibility_to_wrapper( $vars, $slot ); return $this->sanitize_vars( $vars, $this->allowed_vars ); } - For:
public function get( $slot, $template_data = [] ) { global $sitepress; $vars = []; $vars['current_language_code'] = $this->sitepress->get_current_language(); $vars['languages'] = $this->get_language_items( $slot, $template_data ); $vars['css_classes'] = $this->get_slot_css_classes( $slot ); $vars['css_classes_link'] = self::LINK_CSS_CLASS; if(true === $sitepress->get_setting( 'urls' )['directory_for_default_language'] ) { $vars['current_language_code'] = "root"; } $vars = $this->add_backward_compatibility_to_wrapper( $vars, $slot ); return $this->sanitize_vars( $vars, $this->allowed_vars ); }
Still Seeing This Issue?
If updating doesn’t fix it, ask a support question and we’ll look into it with you.
Ask a support question