-
AuthorPosts
-
November 3, 2013 at 5:19 pm #183953
Hello,
Thank you for creating this wonderful and easy to use theme. We’re all really excited about our new website and we’ve spent the last couple of days playing with some of the features and we’ve been astounded by the results. However we’ve stumbled upon a really crucial problem regarding internationalization. This is very important to us since we use German as default and English as a secondary language.
Basically, when creating multilingual content with pages every page is redirected correctly apart from the Homepage. When viewing the homepage in German, the language switcher in the footer redirects the user to the homepage’s English counterpart at http://www.example.com/en/{name-of-the-page} instead of http://www.example.com/en/. The same thing happens when visiting the English version of the website and navigating back to German. This wouldn’t bother me that much if it was just the language switcher, however even the XML sitemap uses the wrong URLs which is pretty bad for SEO.
At first we thought that this is an issue with WPML, so I filled for support at their support forum.
I hope this image carefully crafted in paint will help you visualize the problem and examine the settings:
After trying everything, even doing a clean install with just WordPress, WPML and Enfold, I’ve concluded that the issue resides with the theme itself. I’ve also seen the issue appear on other websites using the theme. We’ve also tried some other commercial themes and they work asNovember 3, 2013 at 6:07 pm #183961Hey toshe!
Please create us an admin account and post the login credentials as private reply – we’ll look into it.
Regards,
PeterNovember 3, 2013 at 6:44 pm #183969This reply has been marked as private.November 4, 2013 at 6:26 pm #184375Hey!
I fixed it. WPML will use the permalink of the translated page in the language switcher dropdown. In your case the “Homepage” was a translation of “Startseite” and thus WPML used the permalinks of both pages in the language switcher – even on the front page. I now set the post status of the translated version of “Startseite” to “Draft” (you can delete this Homepage” entry btw) and added a separate page called “Homepage” to your pages. This entry is NOT a translation of “Startseite” and thus the language switcher works correct now.
Regards,
PeterNovember 4, 2013 at 8:05 pm #184413Hey Peter, thanks for re-configuring the frontpage!
Unfortunately this quick fix is not a solution to the core problem! According to WPML, the correct way to do multilingual frontpages is to have the other languages listed as translations of the frontpage! There are several problems that arise from this issue:
– Automatic Language Redirection by WPML is now broken since there is no translated Frontpage to redirect to;
– Synchronising the translations of the Frontpages becomes harder;
– Permalinks for the homepages now are http://www.example.com/homepage for German and http://www.example.com/en/homepage/ for English;
– This is especially bad for SEO since sitemaps and canonical URLs are long and malformed and do not point to the site’s main URL;
– Not using the wordpress’ built in static pages feature breaks other pluginsPlease make this theme WPML compatible – this is an essential feature!
November 5, 2013 at 9:38 am #184692Hey!
I’ll mark this thread for Kriesi and ask him to fix the issue with the next update. For a quick fix add following code to functions.php:
if(!function_exists('avia_change_wpml_home_link')) { add_filter('WPML_filter_link','avia_change_wpml_home_link', 10, 2); function avia_change_wpml_home_link($url, $lang) { global $sitepress; if(is_home() || is_front_page()) $url = $sitepress->language_url($lang['language_code']); return $url; } }
Best regards,
PeterNovember 5, 2013 at 8:11 pm #184917Hi Peter,
Thanks for the support! The fix you provided somehow comments out the WPML redirect script in the header but it does indeed fix the language switcher links. So redirection still doesn’t work :( The hreflang links generated by WPML are also wrong:
<link rel="alternate" hreflang="de-DE" href="http://www.example.io/" />
<link rel="alternate" hreflang="en-US" href="http://www.example.io/en/homepage/" />
but i think I’ve already mentioned that above (hope it helps when debugging).
In case somebody else is experiencing this: I’ve overwritten the canonical URLs for the frontpages in the SEO plugin, so now Google shows the correct URL. ;)
Of course this is a temporary fix and I hope that Kriesi will look into it :)November 8, 2013 at 9:08 am #186046Hi!
We’ll look into it. If we can find a workaround on our end we’ll include a fix, otherwise I think the Yoast plugin solution is better anyway because you’ve more control over the output.
Regards,
PeterNovember 8, 2013 at 9:15 am #186050Hey!
Ok, I looked into the code and we can’t fix this. The head_langs() function in wp-content\plugins\sitepress-multilingual-cms\sitepress.class.php doesn’t allow us to change the url (there’s no filter / hook which would allow us to replace the url). You can try to contact the WPML support team – maybe they can provide an useful tip or they can add a filter to the function in the next version. Otherwise I recommend to use the Yoast workaround mentioned above and to deactivate the WPML seo setting.
We’d need to overwrite the entire head_langs function at the moment which I don’t want especially because the plugin core files/functions may change and this would break our theme.
Regards,
PeterNovember 8, 2013 at 9:46 am #186054Hi!
If you really want to overwrite the function you can try if following code works
add_action( 'plugins_loaded', 'avia_wpml_seo_fix' ); function avia_wpml_seo_fix(){ global $sitepress; remove_action('wp_head', array($sitepress, 'head_langs')); if($sitepress->settings['seo']['head_langs']){ add_action('wp_head', 'avia_wpml_head_langs'); } } function avia_wpml_head_langs(){ global $sitepress; $languages = $sitepress->get_ls_languages(array('skip_missing' => true)); foreach($languages as $code => $lang){ if($code != $sitepress->get_current_language()){ if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']); printf('<link rel="alternate" hreflang="%s" href="%s" />' . PHP_EOL, $sitepress->get_language_tag($code), str_replace('&', '&', $lang['url'])); } } }
I didn’t test it and we probably won’t include it in the theme files but maybe you can use it as a temporary solution until the WPML devs add a filter to the head_langs function.
Cheers!
Peter -
AuthorPosts
- The topic ‘Enfold + WPML = wrong default pages for languages’ is closed to new replies.