This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 10 replies, has 2 voices.

Last updated by Andreas W. 5 months, 1 week ago.

Assigned support staff: Andreas W..

Author Posts
May 3, 2019 at 3:19 pm #3735985

robertE-2

I am trying to:
Redirect to a translated version of a page.

Link to a page where the issue can be seen:
hidden link

I expected to see:
I expect to be redirected to the German translated version of the hidden link page (hidden link).

Instead, I got:
I am redirected to the wrong URL (in this specific case, the URL is hidden link).

Overall, I would expect WPML to accurately detect the correct, translated version of a URL when the language code is added as a directory in the URL.

I can explore several workaround (e.g., adding redirects via NGINX or using the wpml_permalink filter with the $full_resolution to pull the translated URL (https://wpml.org/wpml-hook/wpml_permalink/)), but is there a reason this isn't redirecting correctly in the first place?

The translated pages exist and can be navigated to using the language dropdown from the hidden link page. Why can't WPML detect the correct redirect when the translated pages exist? Why am I redirect to the wrong URL? How are these wires getting crossed?

Other notes:
* This issue isn't isolated to the German translations. It can be reproduced with other language codes, e.g. 'da', 'zh-hans'
* Other examples: hidden link redirects to hidden link instead of hidden link; hidden link redirects to hidden link instead of hidden link

May 3, 2019 at 9:05 pm #3738053

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting WPML Support.

About the wrong redirects, did you try to verify and edit the permalinks for each page on the WordPress page editor?

In case the editor shows the correct permalinks for each page try to run the site in minimal setup to see if the issue persists.

In order to do so, disable any additional plugin that is not related to WPML and its add-ons. If the issue disappears please start reactivating any plugins, or activate them in small groups. This way please verify at which points the issue appears again to indicate the plugin that is causing the issue.

Also please change to a default theme like TwentySeventeen to see if the issue might be theme related.

Further, you could enable the wp-debug feature to see if there are any current PHP errors given.
More information about how to activate this feature you can find here:
https://wpml.org/documentation/support/debugging-wpml/

Let me know about the outcome of this investigation.

Kind regards
Andreas

May 6, 2019 at 8:11 pm #3752513

robertE-2

Hi, Andreas.

I am able to edit permalinks and navigate directly to pages uses permalinks; however, my question is about redirecting to translated pages using the language code in the URL.

For example, I can go directly to hidden link, but if I try link to this page using the english (base language) permalink and adding the language code (i.e. hidden link), I am not redirected to the correct page. My inquiry is about this redirect not functioning as I would expect.

I've done some other research on the WPML support thread, and I believe this issue may be related to a permalink bug with nested pages since I have not seen this issue with non-nested pages.

Here's a pseudo example of the issue...

This works:
* Untranslated page permalink is `/page`
* Translated page permalink is `/es/pagina`
* Navigating to `/es/page` correctly redirects to `/es/pagina`

This does not work:
* Untranslated page permalink is `/section/page`
* Translated page permalink is `/es/seccion/pagina`
* Navigating to `/es/section/page` does NOT correctly redirect to `/es/seccion/pagina`

May 6, 2019 at 10:05 pm #3752835

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT

Please make a backup of site files and database before providing us access.
If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Kind regards
Andreas

May 7, 2019 at 8:26 pm #3761781

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

The language switcher is redirecting to the homepage, as there are not any translations for the subpage "Thank you". In fact, these pages do not exists yet.
Please complete the translations and let me know if the redirection worked as expected.

Kind regards
Andreas

May 8, 2019 at 3:57 pm #3768819

robertE-2

There are three separate thank-you pages, two of which are translated (/find-a-provider/thank-you and /contact/thank-you). Can you take a look at these pages? I included these details in my initial message with a screenshot showing the pages are translated.

May 8, 2019 at 5:00 pm #3769429

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I am sorry, but I can not really follow your request.

Please go to the page /find-a-provider/thank-you and switch the language in the top admin bar to German. (See screenshot)

Here you can see the pages permalinks which you further can edit directly on the page editor:
Permalink: hidden link

After changing the permalink please go to Settings -> Permalinks and simply click the save option to avoid any 404 errors on your translated content.

When visiting hidden link the page appears as translated.

The same counts for hidden link

Could you please clarify your request? Do you only which to change the permalink?

Kind regards
Andreas

May 8, 2019 at 6:40 pm #3770047

robertE-2

My request is why does hidden link redirect to hidden link and not to hidden link (the translated version of the contact/thank-you page)?

To test this yourself, go to hidden link and you'll be redirected to the wrong page.

May 8, 2019 at 8:57 pm #3771171

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I am sorry, I thought the issue is related to the language switcher.

As far I understand now, the issue is related to the form, once the form has been submitted, corrected? But please let me know if the issue persists with the latest WPML updates before taking any further steps.

Go to Plugins -> Add new -> Commercial and proceed with the available updates.

If the updates will not solve the issue I will need to take a copy of your site for further debugging.

Kind regards
Andreas

May 8, 2019 at 9:57 pm #3771365

robertE-2

I planned on holding off on updating WPML plugins until version 1.3 of ACFML is released since version 1.2 broke content in ACF Options pages (https://wpml.org/2019/05/recent-and-upcoming-changes-in-how-to-translate-acf-options-pages/).

Is there a line item in the WPML changelog for the latest releases that would fix this bug?

May 9, 2019 at 4:44 pm #3778151

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

While debugging your sitew I received an error on the plugins page:

Fatal error: Uncaught Error: Call to undefined function get_field() in /www/miradrywpml_966/public/wp-content/themes/miradry/functions/functions-wp-setup.php:75 Stack trace: #0 /www/miradrywpml_966/public/wp-content/themes/miradry/functions.php(6): include_once() #1 /www/miradrywpml_966/public/wp-settings.php(479): include('/www/miradrywpm...') #2 /www/miradrywpml_966/public/wp-config.php(85): require_once('/www/miradrywpm...') #3 /www/miradrywpml_966/public/wp-load.php(37): require_once('/www/miradrywpm...') #4 /www/miradrywpml_966/public/wp-admin/admin.php(34): require_once('/www/miradrywpm...') #5 /www/miradrywpml_966/public/wp-admin/plugins.php(10): require_once('/www/miradrywpm...') #6 {main} thrown in /www/miradrywpml_966/public/wp-content/themes/miradry/functions/functions-wp-setup.php on line 75

This error is realted to the currently used theme.

Could you please try to run the site in minimal setup to see if the issue persists?

Change to a default theme like TwentySeventeen to see if the issue might be theme related.

Please further disable any additional plugin that is not related to WPML and its add-ons or Contact Form 7 itself without anz third party add-ons.. If the issue disappears please start reactivating any plugins, or activate them in small groups. This way please verify at which points the issue appears again to indicate the plugin that is causing the issue.

Further, you could enable the wp-debug feature to see if there are any current PHP errors given. Follow the insutctions of the following documentation and provide the result of the debug.log file.
More information about how to activate this feature you can find here:
https://wpml.org/documentation/support/debugging-wpml/

Kind regards
Andreas

The topic ‘[Closed] URL redirects to incorrect page when language directory is added to base URL’ is closed to new replies.