Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 3.1.9.3

Resolved in: 3.2

Overview of the issue

The language switcher in secondary languages adds “…/front-page-slug” to the homepage URL when “a static front page” is set.

Workaround

  1. Locate the “get_ls_languages” function in “sitepress-multilingual-cms/sitepress.class.php”
  2. Find the following code block:
    if($lang_page_on_front && $lang[ 'code' ] != $default_language) {
        $lang_page_on_front = icl_object_id($lang_page_on_front, 'page', false, $lang[ 'code' ]);
    }
    
    if($lang_page_for_posts && $lang[ 'code' ] != $default_language) {
        $lang_page_for_posts = icl_object_id($lang_page_for_posts, 'page', false, $lang[ 'code' ]);
    }
    
  3. Replace it with this:
    if($lang_page_on_front) {
        $lang_page_on_front = icl_object_id($lang_page_on_front, 'page', false, $lang[ 'code' ]);
    }
    
    if($lang_page_for_posts) {
        $lang_page_for_posts = icl_object_id($lang_page_for_posts, 'page', false, $lang[ 'code' ]);
    }
    

8 Responses to “Language switcher adds ".../front-page-slug" to the homepage URL”

    • Hi!

      We have tested this again and we couldn’t replicate the issue.

      If you have updated WPML to 3.1.9.4 and still facing this problem, could you please report it in the support forum, so we can better address this case?

      Thanks,
      Andrea

    • You must mean the function location, correct?

      If so, yes 🙂 Thanks for catching the typo. I just corrected it.

      • Yes Sarah, just the typo.

        One more question, should i change the code every time i update the plugin?

        Thanks