404 page in multiple languages using WPML

Hi there.

1
I have two 404 pages in two languages and don’t seem to get the second language version in play using the Theme co 404 add-on.

I tried to do as advised here:

https://theme.co/apex/forum/t/custom-404-page-and-wpml/26857/2 -->
https://theme.co/apex/forums/topic/header-issues-underline-issue-on-edge/

That, however, did not work. Any suggestions?

2
Also; I am trying to accomplish the same function with my two Convert Plus Modal Popups. How do I do that?

Thanks.

Hi there,

  1. The Custom 404 plugin does not support the WPML and cannot be used for each language. I added this as a feature request in our issue tracker.

A temporary solution is that you change the content of the /wp-content/plugins/x-custom-404/views/site/

to:

<?php

// =============================================================================
// VIEWS/SITE/CUSTOM-404.PHP
// -----------------------------------------------------------------------------
// Plugin site output.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Output
// =============================================================================

// Output
// =============================================================================

function x_custom_404_filter_template( $template ) {

  require( X_CUSTOM_404_PATH . '/functions/options.php' );

  if ( ! isset( $x_custom_404_enable ) || ! $x_custom_404_enable ) {
    return $template;
  }

  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 );
  }

  if ( ! is_a( $custom_404_post, 'WP_Post' ) ) {
    return $template;
  }

  GLOBAL $wp_query;
  GLOBAL $post;

  $post = $custom_404_post;

  $wp_query->posts             = array( $post );
  $wp_query->queried_object_id = $post->ID;
  $wp_query->queried_object    = $post;
  $wp_query->post_count        = 1;
  $wp_query->found_posts       = 1;
  $wp_query->max_num_pages     = 0;
  $wp_query->is_404            = false;
  $wp_query->is_page           = true;

  return get_page_template();

}

add_filter( '404_template', 'x_custom_404_filter_template' );
  1. You will need to use the manual display behavior option of the ConvertPlus and add a shortcode to the page in question. Then you can create separate ConvertPlus version for each language and add the proper shortcode of it to the proper page in the language in question.

For more information about manual display behavior:

Thank you.

1 Like

Hi there.

Cf 1

Unfortunately, that didn’t work. I get the following error:

Warning: require(X_CUSTOM_404_PATH/functions/options.php) [function.require]: failed to open stream: No such file or directory in /var/www/mohocon.com/public_html/wp-content/plugins/tco-custom-404/views/site/custom-404.php on line 20

Warning: require(X_CUSTOM_404_PATH/functions/options.php) [function.require]: failed to open stream: No such file or directory in /var/www/mohocon.com/public_html/wp-content/plugins/tco-custom-404/views/site/custom-404.php on line 20

Fatal error: require() [function.require]: Failed opening required 'X_CUSTOM_404_PATH/functions/options.php' (include_path='.') in /var/www/mohocon.com/public_html/wp-content/plugins/tco-custom-404/views/site/custom-404.php on line 20

Would you have other suggestions?

Cf 2

The available solutions require a user driven event. I want it to appear automatically. So, I guess the best option is to define the pages in question manually within the ConvertPlus configuration / control panel.

Thanks

Hi there,

  1. Unfortunately, the solution I provided is not working on the new version of the plugin. I double checked the case and it indeed is changing and it is not possible to use quick code fixes to make it compatible now. I am afraid you will not be able to use the plugin with the WPML at the moment. Please consider the alternative 3rrd party plugins regarding this. Rest assured that the feature request is already in our issue tracker and if there are enough people asking for this it will be considered for the implementation.

  2. Unfortunately, there is no automated option for this case in question to support a multilingual case.

Thank you for your understanding.

1 Like

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