Theme Author
Tom
(@edge22)
Hi there,
I wonder if a plugin like this would help?: https://wordpress.org/plugins/404page/
That way you should just be able to translate the page you set as the 404 page.
Let us know 🙂
The 404 page should appear in the language of the subsite just like all other sections of WordPress. Without the individual users or I have to take care of it.
This should be possible without an extra plugin
Hi,
You can try this approach:
add_filter( 'gettext', function( $text ) {
if ( 'Oops! That page can’t be found.' === $text ) {
if( 'en_US' == get_locale() ){ return 'Your new text in english'; }
if( 'fr_FR' == get_locale() ){ return 'Your new text in french'; }
}
if ( 'It looks like nothing was found at this location. Maybe try searching?' === $text ) {
if( 'en_US' == get_locale() ){ return 'Your new text in english'; }
if( 'fr_FR' == get_locale() ){ return 'Your new text in french'; }
}
return $text;
} );
It gets the text and translates it depending on the get_locale() value.
You can change/add more if( 'locale_LOCALE' == get_locale() ) conditions if you want to add more languages.
You can use this as reference for the WordPress locale languages.
https://wpastra.com/docs/complete-list-wordpress-locale-codes/
Thank you, that works!
Glad it works for you. No problem. 🙂