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.

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)

This topic contains 7 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 1 month ago.

Assisted by: Long Nguyen.

Author Posts
October 5, 2023 at 9:21 am #14518629

vanessaS-12

I am trying to: change language of a post that has a translation in spanish saved as draft

Link to a page where the issue can be seen: hidden link

I expected to see: changed language to spanish, but showing content in default EN

Instead, I got: 404 - Page not Found

October 6, 2023 at 2:45 am #14523661

Long Nguyen
Supporter

Languages: English (English )

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

Hi Vanessa,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

According to the debug log, I see the post translation preference is "Translatable - use translation if available or fallback to default language" in WPML > Settings.
If the translation of the post is in Draft mode, only the administrator can view it. You can go to the admin area > Edit the post in English > Switch the language to Spanish with the language switcher at the topbar > Publish or delete it to allow the visitor to view the English content when switching to Spanish in the frontend.

Look forward to your reply.
Thanks

October 6, 2023 at 6:49 am #14524265

vanessaS-12

yes, indeed I have enabled that setting to show up the content in English by default.

But while I'm translating a post (in Spanish for example) which could take more days, I don't want a visitor who clicks on Spanish from the English post to get a 404 message, but still the English content (as the translation is not yet published)

That seems a bug to me.
you can really reproduce this while on this post: hidden link

I hope it's more clear now.
Thanks!

October 6, 2023 at 7:54 am #14524809

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

I see the issue on that post. It is expected behavior when the translation of the post is in Draft mode. You can consider switching the translation preference of the post to "Translatable - only show translated items" in WPML > Settings > Post Type Translation, to display only translated posts in the frontend.

Look forward to your reply.
Thanks

October 6, 2023 at 11:30 am #14526913

vanessaS-12

Hi,
I cannot switch to "Translatable - only show translated items" as we want to show on the blog page all posts (english and other languages when translation is available) to avoid that the page looks too empty.

As I already mentioned, there could be cases when we are working on a translation and it will be saved as draft for several days, and I don't really think that it should be the expected behaviour to give the user a 404 error when he tries to switch on spanish..

I'm really looking forward to find a workaround for this issue!

Thanks!
kind regards

October 9, 2023 at 1:45 am #14535623

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

Please try this workaround to use the translation memory in Advanced Translation Editor (ATE) as the draft translation and let me know if it helps.

1. Edit the post in English language > Switch to WordPress editor > Duplicate the post into Spanish language.
2. Switch back to WPML editor > Click on the Pen icon to translate the post in ATE.

Then the English content will be displayed in Spanish language (duplicate), and you can still continue translating the content in ATE.

Refer documentation https://wpml.org/documentation/translating-your-contents/using-different-translation-editors-for-different-pages/
https://wpml.org/documentation/translating-your-contents/how-wpml-keeps-track-of-your-translations/

Look forward to your reply.
Thanks

October 13, 2023 at 7:07 am #14570245

vanessaS-12

Hello!
I'm afraid this solution is not scalable and not good enough (btw I'm not using ATE for page translations), it seems too complicated, especially when I have to do this for multiple pages.
Sorry but this still seems to me a bug and should never be be an expected behaviour.

It reminds me of an old issue where draft translations where listed in the wp_query and were giving the same 404 message until you fixed it in an update.

I would expect you do the same with this issue, please.

Thanks a lot!

October 13, 2023 at 9:36 am #14571677

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

Thanks for your reminder. If you are using the workaround that my colleague shared before (https://wpml.org/forums/topic/error-trying-to-list-my-posts-using-wp_query/#post-13671265), please adjust the code:

- Edit the file wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php

- On line 299, replace the code

if (get_post_status($element["element_id"]) == "draft" || get_post_status($element["translation_id"]) == "draft") {

with this one

if ( !is_admin() && (get_post_status($element["element_id"]) == "draft" || get_post_status($element["translation_id"]) == "draft")) {

❌ IMPORTANT: Please backup your database and website before proceeding ❌

This will fix the issue with the connection of the translation post in the admin area.

Look forward to your reply.
Thanks

The topic ‘[Closed] Error when changing the language on a post that has no published translation’ is closed to new replies.