Custom 404 page and WPML

I have enabled the custom 404 plugin. The URL are:

So, if we click (or type) a wrong link from a translated page, it will show the original (Spanish) custom 404 page instead the translated version.

Any way to fix it?

Thanks!

Carlos

Hi there,

Thanks for writing in.

Could you try the suggestion here https://theme.co/apex/forums/topic/header-issues-underline-issue-on-edge/#post-881406. Then let me know how it goes, we may need to change 404 redirection as this should be fixed long ago.

Thanks!

It does not work. Actually it’s worse now. It only shows the title in the case of the original version, and the translated version redirects to home.

I’m going to switch back to the previous version

Hi there,

In that case, please provide your admin and FTP login credentials in a secure note. I like to check and test it directly.

Thanks!

Please, see the details in the secure note.

Thanks

Carlos

Hi there,

I checked and the code from that thread isn’t implemented. I went ahead and added the fix.

  global $sitepress;

  if ( function_exists( 'icl_object_id' ) && is_callable( array( $sitepress, 'get_current_language' ) ) ) {
      $custom_404_post = get_post( icl_object_id( $x_custom_404_entry_include, 'page', false, $sitepress->get_current_language() ) );
  }
  else {
      $custom_404_post = get_post( (int) $x_custom_404_entry_include );
  }

It should be okay now.

Thanks!

Hi. I suspect you shared the wrong thread.

Whatever you shared the wrong thread or I did not see the correct solution, what I did was “navigate to this folder \wp-content\plugins\x-custom-404\views\site\ Then edit custom-404.php and replace the entire code with…” That approach didn’t work.

Anyway, your code seems to work almost perfect. The only issue is that if someone who speak English and enter in a wrong page like:

I guess that person will click on the English flag to see the text in English. However, it won’t show the text in English as when the person clicks on the flag, the page redirects to the home page.

Thanks for your help and I’m sorry for your anger

Carlos

For the redirection, it’s reasonable since an Error 404 text is already showing which can be easily understood by users without being translated to English.

On my behalf of my colleague, you’re welcome and no worries. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.