Skip to content Skip to sidebar

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

Problem:
The client wants to have separate 404 pages for different languages instead of a single redirect via the 404.php page.
Solution:
We recommend the following steps to create language-specific 404 pages:
1. Ensure that the strings on the 404 page are wrapped in the gettext function. You can find more information on how to enable text translation for themes not compatible with WPML in our documentation: Enabling Text Translation for Themes Not Compatible with WPML.
2. Scan your theme for strings by navigating to WPML >> Theme and plugins localization, select your theme, and click the “Scan selected themes for strings” button.
3. Translate the required strings by going to WPML >> String Translation, searching for the strings, and adding their translations.
4. Use the

wpml_current_language

hook to get the current language and display or include content accordingly. For more details, check out our documentation: wpml_current_language Hook.

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 1 reply, has 2 voices.

Last updated by Noman 1 year, 5 months ago.

Assisted by: Noman.

Author Posts
January 20, 2024 at 9:41 pm #15207714

suzyG

Can we have separate 404 pages per language?
i.e. for English one 404...for German customers a different 404 page.

Right now we have a single re-direct via the 404.php page.

January 21, 2024 at 10:20 am #15208120

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. Sorry, it’s not possible to have separate 404 pages using the built-in feature of WPML. You may try to achieve it by following the below steps:

1. You should be able to translate the 404-page text by following the below steps:

- Please make sure the strings in the 404 page are wrapped in the gettext function as mentioned here in this doc: https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

- Go to WPML >> Theme and plugins localization page, select your theme, and press the “Scan selected themes for strings” button.

- Go to WPML >> String Translation page, search your required strings, and add the translation.

2. You may get the current language using wpml_current_language hook and display/include the content according to your needs. Here is a doc for more details:
https://wpml.org/wpml-hook/wpml_current_language/

Please let me know if this resolves your issue or if you need further assistance with this issue.

Thank you