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
- Locate the “get_ls_languages” function in “sitepress-multilingual-cms/sitepress.class.php”
- 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' ]); }
- 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' ]); }
This patch fixes the issue reported here: https://wpml.org/forums/topic/hreflang-issue-on-homepage-all-sites
Although, to mention, the point 2 of the full description is incorrect. Even if the homepage is created in the first language (French for my websites) then translated to English, the issue is present.
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
We are using 3.1.9.6 and are still experiencing this. I added the workaround as described here.
Indeed. The fix will be released in 3.2
the correct is in folder sitepress-multilingual-cms , file: sitepress.class.php
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
The workaround is not needed if you are using 3.2 RC3 🙂