Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client wants to configure WPML so that if a page does not exist in a specific language, accessing the URL for that language version returns a 404 error, instead of redirecting to the original language or displaying the content in the default language.

Solution:
1. We identified that the issue occurs only when the client's Child Theme is active.
2. To resolve the issue, we suggested commenting out lines 3 to 13 in the functions.php file of the Child Theme.
3. We explained that WPML's default behavior is to redirect to the original content if a translation does not exist, which is generally beneficial for SEO.
4. We mentioned that disabling this behavior would require custom code using hooks such as

wpml_is_redirected

and

template_redirect

.
5. We provided links to the relevant documentation:

6. We informed the client that this customization goes beyond WPML's integrated functionality and our support policy, which can be found here: https://wpml.org/purchase/support-policy/.
7. For further assistance, we recommended seeking help from an experienced developer and provided a link to find contractors: https://wpml.org/contractors/.

If this solution does not seem relevant to your situation, please open a new support ticket at our support forum.

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 8 replies, has 2 voices.

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

Assisted by: Andreas W..

Author Posts
January 5, 2024 at 2:29 pm #15155141

tonyS-19

Hi,

I have a translation plugin installed on the website called WPML.
I have development domains:
hidden link
hidden link

I would like to know how to disable the default language when the translation for a particular page does not exist in that language.

For example, we have a page: hidden link that does not exist in English, yet it appears under the domain hidden link, even though it is only created in German.

This is evident when I click "Edit Page" for the English version -> hidden link because it redirects me to the editing page in German -> hidden link

I would like to configure it so that if a page does not exist in a specific language, accessing such a link returns a 404 error.
So, for example, if someone tries to access the URL hidden link, they should receive a 404 error. It should only work for the link hidden link.

Help me please in the proper configuration.

Best regards,
Jakub

January 5, 2024 at 2:36 pm #15155204

Andreas W.
WPML Supporter since 12/2018

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

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

Hallo Jakub,

Kann es sein, dass Du unter WPML > Einstellungen > Beitragstypen übersetzen eingestellt hast, das für Seiten, die nicht übersetzt sind, der originalen Inhalt angezeigt werden soll?

Mehr dazu hier:
https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/

Mit freundlichen Grüßen
Andreas

January 10, 2024 at 3:19 pm #15169689

tonyS-19

Hello Andreas,

I have it set to "Translatable - only show translated items"

Could you check it?

Thank you in advance.

Best regards,
Jakub

W6IZ94W.png
January 10, 2024 at 3:50 pm #15169926

Andreas W.
WPML Supporter since 12/2018

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

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

Your example:
hidden link

Please verify on your pages list if there are by mistake pages with German content are created in English languages.

Further, take note that this example content is translated:

DE > hidden link
EN > hidden link

January 12, 2024 at 10:45 am #15178369

tonyS-19

Unfortunately, I don't know where the error is.

I have a website hidden link
Where I don't see any translations done in the CMS for EN -> hidden link

Could you take a look at this in my DEV version?
I can send you the access?

Thank you in advance

January 12, 2024 at 11:50 am #15178787

Andreas W.
WPML Supporter since 12/2018

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

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

Hello,

Sure, I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the website to investigate this issue further.

You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it.

IMPORTANT
Please be sure to make a backup copy of the website and database before allowing us access.
If you can't see the wp-admin / FTP fields, your post and website credentials are set as PUBLIC. DO NOT publish the data unless you see the required wp-admin / FTP fields.

The private response form looks like this:
hidden link

Next time you reply, click "I still need assistance."

Video:
hidden link

Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form.

Best regards
Andreas

January 12, 2024 at 1:53 pm #15179478

Andreas W.
WPML Supporter since 12/2018

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

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

This issue only occurs if your Child Theme is active.

Commenting our lines 3 to 13 of your functions.php file solves the issue.

January 12, 2024 at 2:32 pm #15179615

tonyS-19

Thank you, it works well because when entering from the version hidden link, I receive a 301 redirection to the version hidden link.

Is it possible to configure it so that this redirection does not occur, and entering hidden link results in a 404 error?

January 12, 2024 at 3:44 pm #15179986

Andreas W.
WPML Supporter since 12/2018

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

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

It is the WPML default behavior, as it will always redirect to the original content if a translation does not exist. This includes, that we do not have any entry yet for this untranslated content in our language tables, and this is why we force to redirect to the original content.

This behavior makes sense, as it might be better for your SEO rating and there is usually no way, that based on the site's navigation and WPML's internal linking feature someone would even land on content, that never was translated unless they manually enter the URL inside the address bar of the browser.

The only exception would be if the user uses custom menu items or custom links that point to untranslated content.

Usually, to disable this behavior you could use these hooks:
https://wpml.org/wpml-hook/wpml_is_redirected/
https://developer.wordpress.org/reference/hooks/template_redirect/

I tried to test this, but could not come up with a working solution for your use case yet and can sadly not spare more time for running further tests at the moment.

Please take note, that this request goes beyond the integrated functionality of WPML and such a request is not covered by our support policy:
https://wpml.org/purchase/support-policy/

You can find contractors on the following link, in case you need assistance from an experienced developer:
https://wpml.org/contractors/

I hope for your understanding.