Resolved
Reported for: WPML Multilingual CMS 4.6.8
Resolved in: WPML 4.6.9
Overview of the issue
Users with WordPress installed in a sub-folder and using the WPML feature Use directory for default language are experiencing incorrect URL generation for taxonomy archives and custom post type links. This results in doubled paths in the URL and the consequently 404 errors when trying to access to these pages.
For example, you will get redirected to http://www.domain.com/subfolder/en/subfolder/en/category/new-category/
instead of http://www.domain.com/subfolder/en/category/new-category/
.
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-content/plugins/sitepress-multilingual-cms/classes/canonicals/class-wpml-canonicals-hooks.php file.
- Look for line 87.
- Change:
public function redirectArchivePageToDefaultLangDir() { global $wp_query; $isValidForRedirect = $wp_query->is_archive() && ! call_user_func( $this->is_current_request_root_callback ); if ( ! $isValidForRedirect ) { return; } $currentUri = $_SERVER['REQUEST_URI']; $lang = $this->sitepress->get_current_language(); if ( 0 !== strpos( $currentUri, '/' . $lang ) ) { $canonicalUri = user_trailingslashit( $this->url_converter->get_abs_home() . '/' . $lang . $currentUri ); $this->redirectTo( $canonicalUri ); } } private function redirectTo( $uri ) { $this->sitepress->get_wp_api()->wp_safe_redirect( $uri, 301 ); }
- For:
public function redirectArchivePageToDefaultLangDir() { global $wp_query; $isValidForRedirect = $wp_query->is_archive() && ! call_user_func( $this->is_current_request_root_callback ); if ( ! $isValidForRedirect ) { return; } $currentUri = $_SERVER['REQUEST_URI']; $lang = $this->sitepress->get_current_language(); if ( 0 !== strpos( $currentUri, '/' . $lang ) ) { $realhome = get_option('siteurl'); $parsed = parse_url($realhome); if (false !== strpos($currentUri, $parsed["path"])){ return; } else { $canonicalUri = user_trailingslashit( $this->url_converter->get_abs_home() . '/' . $lang . $currentUri ); } $this->redirectTo( $canonicalUri ); } }
I can confirm this issues, when will the fix be released?
Hey there,
I can’t provide you an ETA, but this is definitely in our developers roadmap.
I’ll update this erratum as soon as we have a new version with a fix coming.
Hello everyone,
This issue should have been solved with WPML 4.6.9.