Skip Navigation

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.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by philipC-9 2 months ago.

Assigned support staff: Alejandro.

Author Posts
September 14, 2021 at 10:22 am #9582785

philipC-9

For the 404 errors, I deactivated every plugin possible (except for WPML ones) and the 404 error still occurred when simply viewing the KnowledgeBase and simply changing from English in the top menu bar to French. This did NOT occur when I switched from the "Knowall Child Theme" to the "Twentytwentyone" theme. I assume this is an incompatibility issue that I need KnowAll/HeroThemes to fix? Thanks.

September 14, 2021 at 10:37 am #9582911

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Can you confirm the problem happens ONLY with the knowledgebase elements and not with pages or posts?

If it only happens with the knowledgebase, and that feature comes from the theme and not another plugin, then please ask the authors of the plugin the following questions:

- Are they compatible with the latest WPML release?
- Have they tested it with the configuration of your case scenario (please describe the situation to them).

------------------------

In the meantime, please try to recreate the problem here: hidden link

add the theme, add the WPML configu you have on your site and let's see if the 404 errors happen here as well.

Thanks in advance.

September 22, 2021 at 4:52 pm #9639861

philipC-9

Sorry for the delayed response. This problem happens with pages as well (viewing the list of pages and trying to switch to any other language results in a 404 error), so it's not specific to the HeroThemes theme we are using. It also doesn't happen with their parent theme (only in our child theme which has some php customizations you/WPML provided to work around other issues: URL redirect issue with translations and a search issue). We are looking into whether it is the WPML-provided coded that is causing this 404 error. I will let you know if it is. In the meantime, since it happens with Pages as well, let me know if you want to look at it in our staging environment. Thank you!

September 23, 2021 at 6:56 am #9643027

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

you had mentioned:

This did NOT occur when I switched from the "Knowall Child Theme" to the "Twentytwentyone" theme

This probably means the problem exists within the knowall theme, since the problem only seems to happen when that theme is enabled.

The reason why i had asked you to recreate the problem on the staging site is so we can easily isolate the problem: if with only the theme installed, you still get 404 errors, then the problem can be escalated to our developers so they can try to find a workaround for you.

Please try to recreate the problem here: hidden link

In order to do so you only need to install the theme first and try to get the 404 errors on pages. if the problem doesn't exist here, then try to see if by installing theme related plugins, the problem starts to reappear.

Let me know how it goes and kindly let me know the steps to recreate the problem if it reappears.

September 23, 2021 at 2:25 pm #9647067

philipC-9

We were able to work-around this issue by editing the custom code you (WPML) previously provided to fix broken translated links. This was done by adding "&& !isset($_GET['admin_bar']" to the condition below. Thank you for your willingness to help us debug this issue. It is sufficiently resolved for now.

/* Fix for broken translated links */

add_action('wp', function (){
if (!empty($_GET['lang']) && !isset($_GET['s'])) {
$active_langs = get_transient('wpml_active_languages');
if (empty($active_langs)) {
$active_langs = apply_filters( 'wpml_active_languages', '' );
set_transient('wpml_active_languages', $active_langs, 24 * HOUR_IN_SECONDS);
}

if (isset($active_langs[$_GET['lang']]) && !isset($_GET['admin_bar'])) {
$valid_code = filter_input(INPUT_GET, 'lang');
$url = parse_url($_SERVER['REQUEST_URI']);
$rdr_url = !empty($url['path']) ? rtrim(site_url(), '/') . '/' . $valid_code . '/' . ltrim($url['path'], '/') : rtrim(site_url(), '/') . '/' . $valid_code . '/';
wp_redirect($rdr_url, 301);
exit;
}

}

return;

});