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 3 voices.

Last updated by Andreas W. 4 months, 2 weeks ago.

Assigned support staff: Andreas W..

Author Posts
May 23, 2019 at 7:39 pm #3879105

robertE-2

I need to reopen the following support ticket: https://wpml.org/forums/topic/url-redirects-to-incorrect-page-when-language-directory-is-added-to-base-url/

The WPML support team member caused an error on the site and I need to know what change was made so that I can recreate and debug.

May 24, 2019 at 5:54 am #3881297

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi there,

I will reassign the ticket to Andreas since he has all the information about our issue, I hope he would be of great help.

Regards
Raja

May 24, 2019 at 1:51 pm #3885403

robertE-2

Thank you, Raja!

May 24, 2019 at 2:06 pm #3885467

Andreas W.
Supporter

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

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

Hello,

Thank you for reaching out to the WPML Support Forum.

When accessing your site the following error is displayed:

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/index.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

Please verify line 75 of your theme's functions.php file and verify the get_field() function. As far the error shows, your custom code for implementing Advanced Custom Fields into your theme was not set correctly.

In order to obtain instant access to your site please I would advise you to connect to your site by FTP and rename the theme folder for the currently used theme to something like theme-name-disabled. Afterwards login to your site and activate temporarily a default theme like Twenty Seventeen.

I would like to point out again that this error is theme related and I was not able to onvestigate further about as the provided FTP credentials do not grant access to your server (access denied).

Could you please paste the above mentioned get_field() function inside your next message in order to assist you further?

Kind regards
Andreas

May 24, 2019 at 4:23 pm #3886209

robertE-2

Hi, Andreas.

Luckily, I created the miradrywpml.kinsta.cloud site as a duplicate for the WPML support team to play around with. Looks like those error messages were caused when you deactivated the advanced-custom-fields-pro plugin. get_field() is an ACF function, when the plugin is disabled, this causes a fatal error.

I've commented out the get_field() functions from my functions/functions-wp-setup.php file and am now able to access some version of the site (although each page of the site is blank because the site is built using ACF).

However, I am concerned that the WPML support team still isn't following along with the issue I detailed out in my initial inquiry (https://wpml.org/forums/topic/url-redirects-to-incorrect-page-when-language-directory-is-added-to-base-url/). The issue is not form related, it has to do with how WPML handles urls and redirects.

You can see the issue on the following site: hidden link

Use the following steps to recreate the issue:
* Go to hidden link (/find-a-provider/thank-you)
* Use the language drop down to select Dansk
* Verify that you are taken to the Danish version of the /find-a-provider/thank-you page at hidden link (/da/find-en-udbyder/tak-2/)
* In a separate tab, go back to hidden link (/find-a-provider/thank-you)
* Add the language directory (/da/) to the web address, i.e. hidden link (/da/find-a-provider/thank-you/)
* Rather than being taken to the Danish version of the find-a-provider/thank-you page, you are taken to a separate thank-you page (hidden link)

Since the Danish version of the /find-a-provider/thank-you page clearly exists, why doesn't adding the language directory to the URL resolve to the Danish version of the page?

May 24, 2019 at 4:28 pm #3886265

robertE-2

If you send me a secure form input, I can resend the SFTP credentials.

May 27, 2019 at 6:18 pm #3900181

Andreas W.
Supporter

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

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

Hello,

The redirect refers to the fact that the URL hidden link does not exists.

It might be a default behvior of the theme to redirect to hidden link - Usually the redirect should get back to the homepage or a 404 page, if a URL does not lead to existing content.

Anyhow, following your instructions I receive the same result if WPML and any other plguin is disabled, which for this is not an WPML issue. You might test this yourself. Please contact the theme support here:
hidden link

The correct URL for Dansk is hidden link and this is also reached when using the WPML language switcher.

Kind regards
Andreas

May 28, 2019 at 9:16 pm #3910255

robertE-2

I understand that the /da/find-a-provider/thank-you page does not exist with that URL (though the Danish translation of the /find-a-provider/thank-you page does exist at /da/find-en-udbyder/tak-2). What I don't understand is why WPML doesn't correctly redirect to the translated page based on how WPML can correctly redirect to other pages by adding the language directory.

I included some pseudo-code on my previous support ticket that outlines this behavior (https://wpml.org/forums/topic/url-redirects-to-incorrect-page-when-language-directory-is-added-to-base-url/#post-3752513):

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`

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.

Can you provide any insight on why this redirect behavior is inconsistent?

Thanks!

May 30, 2019 at 2:59 am #3919945

Andreas W.
Supporter

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

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

Hi,

Thank you for your message.

I am cosulting our second tier support about the redirect rules and if there is some kind of workaround we might be able to offer.

It seems to me that it is not WPML default behavior and I will clarify that. Anyhow, as mentioned earlier, the redirect to hidden link is also occuring when WPML is deactivated. I am further, clarifying with our second tier support if WPML would be able to achieve such kind of redirects.

Once I received feedback I will be in contact with you again.

Kind regards
Andreas

May 30, 2019 at 1:46 pm #3923487

robertE-2

Thank you, Andreas!

May 30, 2019 at 2:41 pm #3923953

Andreas W.
Supporter

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

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

Hello,

Our second tier support informed me that the redirection is based on WordPress.
https://codex.wordpress.org/Function_Reference/redirect_canonical

This is why the redirection also occurs if WPML is disabled.

You can achieve different redirections by using a Plugin. I can recommend you the following plugin, as it has been tested with WPML for compatibility.
https://wordpress.org/plugins/redirection/

More information about plugins and their compatibility with WPML you can find here:
https://wpml.org/documentation/plugins-compatibility/?wpv_view_count=119945&dev=0&wpv-plugin-functionality=0&wpv_post_search=&wpv_filter_submit=Search

Kind regards
Andreas