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.

WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 7 replies, has 0 voices.

Last updated by Long Nguyen 1 week, 5 days ago.

Assisted by: Long Nguyen.

Author Posts
October 29, 2024 at 9:09 am #16340800

Ahliman maelT

Background of the issue:
I am encountering an issue with WPML where, if a product is published in the default language 'en' and has a translation in 'en-us' that is currently in 'draft' status, WPML still tries to generate a link in 'en-us' instead of falling back to the 'en' version. The code I am using is: $defaultLocale = apply_filters('wpml_default_language', null); return apply_filters('wpml_permalink', get_the_permalink(20), $defaultLocale). Link to a page where the issue can be seen: hidden link.

Symptoms:
When I try to retrieve the link for this product while the site is set to 'en-us,' WPML returns a URL with the 'en-us' prefix (e.g., hidden link), even though the 'en-us' version is not published. I expected to see: hidden link. Instead, I got: hidden link.

Questions:
How can I adjust the fallback logic to ensure WPML provides the link to the 'en' version when the 'en-us' translation is in 'draft' status?

October 29, 2024 at 9:47 am #16341095

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Here is the forum ticket. I would like to request temporary access (wp-admin and FTP) to your site so I can take a better look at the issue. It would be better to have a testing site where the issue is replicated. Your next reply is set to private to share the info.

❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: https://wordpress.org/plugins/duplicator/
✙ I would need your permission to de-activate and re-activate Plugins and the Theme to change configurations on the site if needed. This is also a reason the backup is critical.

Looking forward to your reply.
Thanks

October 29, 2024 at 9:48 am #16341096

Ahliman maelT

I was typing to add credentials to access to my website, but Long Nguyen transformed the chat to the forum ticket without my confirmation

October 29, 2024 at 10:35 am #16341391

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I would like to request temporary access (wp-admin and FTP) to your site so I can take a better look at the issue. It would be better to have a testing site where the issue is replicated. Your next reply is set to private to share the info.

❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: https://wordpress.org/plugins/duplicator/
✙ I would need your permission to de-activate and re-activate Plugins and the Theme to change configurations on the site if needed. This is also a reason the backup is critical.

Looking forward to your reply.
Thanks

October 29, 2024 at 12:36 pm #16342166

Ahliman maelT

Ok I found the problem, it is a "bug" for me.

If some one technical can answer it will be perfect

The problem comes from "get_the_permalink" function and "wpml_permalink" filter.

The "get_the_permalink" will return the product in the current language "en-us"

If the product in "en-us" is in Draft mode, it will return the preview URL and the filter "wpml_permalink" will just replace the language so we will get the preview URL.

The "wpml_permalink" must detect if the url is a preview URL, if yes, it should return the correct value for the translation, or we should get the ability to edit it with a parameter

October 30, 2024 at 2:56 am #16344577

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I've tried to replicate the issue on a clean WordPress installation and confirmed the issue. This happens when the option auto adjust ID is enabled, you can go to WPML > Languages > Disable option "Adjust IDs for multilingual functionality" and recheck this.

Please check the attached screenshot and the sample code below:

$permalink = get_the_permalink( 100 ); // 100 is the translation post ID
echo "Permalink: " . $permalink;
echo "<br>";

$wpml_permalink = apply_filters( 'wpml_permalink', $permalink, 'fr' ); 
echo "WPML Permalink: " . $wpml_permalink;

If you want to test, please click this link hidden link
to access the sandbox site admin area.
The code is added to the theme folder > template-parts/content/content-page.php

Looking forward to your reply.
Thanks

Sandbox – Just another WordPress site 2024-10-30 09-43-11.png
November 4, 2024 at 8:12 am #16359072

Ahliman maelT

Hi Long Nguyen,

Thanks, it looks working but let me some days to check the website globally to see this settings impact, I will come back here to give news

November 4, 2024 at 8:46 am #16359355

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

I'm waiting for your feedback.

Thanks.

November 12, 2024 at 4:26 pm #16393858

Ahliman maelT

Hi,

After checking it internally with our team, disabling this option causes some issues, I will back soon to provide more information, I am waiting an answer from some people

November 14, 2024 at 1:25 am #16400359

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Sure, let me know if you have any questions.

Thanks.