Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.5.12

Resolved in: 4.6.0

Topic Tags: Bug

Overview of the issue

If you are using the horizontal list or vertical list display options for any of the language switchers on your site, the order is not consistent when you switch languages on the front-end. Instead, the current language will always be displayed in first position, despite your settings.

Workaround

Please, be sure of making a full backup of your website.

  1. Open the /sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-model-build.php file.
  2. Look for line 244.
  3. Replace:
    			$ret = $this->order_menu_items( $ret, $this->sitepress->get_current_language() );
    

    With:

    			if (! $slot->get( 'display_link_for_current_lang' )) {
    				$ret = $this->order_menu_items( $ret, $this->sitepress->get_current_language() );
    			}
    

10 Responses to “WPML 4.5.12 - Language switcher list changes order when switching languages”

    • Hello there,
      We haven’t released a new release including a fix yet. Could you please follow the workaround here presented in the meantime?
      Regards

    • I see your point, but it is not precisely the same issue.
      We will update this erratum as soon as a new release include this fix.
      Thank you for your understanding.

    • I’m glad to know the workaround still works. We will update here once we launch a new version fixing this issue.
      Regards

  1. fyi: Fix didn’t work on our site.
    WPML: Version 4.5.14
    php 8.2

    Site crashed, error-message:
    Parse error: syntax error, unexpected variable “$ret” in (…)/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-model-build.php on line 245