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.

Our next available supporter will start replying to tickets in about 3.37 hours from now. Thank you for your understanding.

This topic contains 12 replies, has 3 voices.

Last updated by Marcel 3 days, 6 hours ago.

Assisted by: Marcel.

Author Posts
September 13, 2024 at 4:08 pm #16176816

kirily-2

Background of the issue:
We are experiencing issues with translating template parts with WPML. On save, calls to hidden link result in a 404 error, while calls to hidden link (default language, which is Romanian) work as usual. Here is a screenshot as well: hidden link

Symptoms:
404 error when saving translated template parts.

Questions:
Could you please advise what might be the issue?

September 15, 2024 at 2:19 pm #16180172

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Please make sure that the template part in question is translated via WPML > Translation Management.

And I guess by template part you mean the one used in Full Site Editing themes.

The other point is that after the translation you need to use the slug of the translated template part and most probably add the code of the second language on the URL.

You can always use the hook below to get the ID of the template part in another language and print it to see what is the correct URL you should use:

https://wpml.org/wpml-hook/wpml_object_id/

Thanks.

September 16, 2024 at 2:56 pm #16184587

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you. I checked and it seems that you translated the template part already.

Now I checked the URL that you shared before I can see that even with the main language you have mentioned it does not show information and code f the footer.

It says "You do not have access to the site templates".

I also found out the URL you shared had many double slashes //

Can you double check and give me the correct URL regardless of WPML, and the original language?

Thanks.

September 17, 2024 at 8:22 am #16186786

kirily-2

Hello,

We translated the template part with auto translate but some content has to be changed accordingly (e.g. addresses).

The main language does not show the lang code, however, it saves without any problem.

The double slashes are correct - as on the main language.

"You do not have access to the site templates" - it is when you try to open the WP API url directly, but when accessed via ajax (the normal workflow) it returns 404.

Best regards!

September 17, 2024 at 11:52 am #16188132

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

hi,

It is hard for us to troubleshoot something that only can be accessed via Ajax code.

Would you please provide a way that we can follow step by step to see the issue so I can report this to the second-tier support?

Usually by simply adding the language code at the beginning of the URL after the domain it should work correctly.

Also we will need you to provide a scenario that there is no other plugin that might cause conflict by deactivating all other plugins and keeping only the theme in question.

Thank you.

September 18, 2024 at 7:25 am #16191269

kirily-2

Hello,

Ajax is how WordPress works, it is not our choice to use it or not.

Unfortunately, we cannot add the option for sub domain per language as we already have a subdomain - this is development env.

The website is based on Elementor so we cannot deactivate it. However, we have tried deactivating the others.

To summarise - the issue occurs when trying to save a template part in different than the main language. The WP API url returns 404 with the lang code included, while it works when no lang code included (default language has no lang code).

Best regards!

September 18, 2024 at 12:43 pm #16193052

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for the info. I'd appreciate it if you could provide the login information of a website copy so we can investigate. You can set the next reply as private.

What we will need is the login info of a version of the website that is not important if something breaks in. And also please ask your developers to provide a simple script that we can check maybe on the functions.php of the default WordPress theme to see how they want to retrieve the content from Rest API and I will relay al the information to the second tier support to check.

Thanks.

September 19, 2024 at 12:50 pm #16198810

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

The login link goes to a 404 page:

hidden link

Also, You did not mentioned where to see the sample code I mentioned you need to provide so we can see how you try to access the rest API in the code.

Thanks.

September 22, 2024 at 8:42 am #16205625

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for the login information. I managed to log in. In the description of the latest reply, you mentioned that there is no code and you have issues translating content via WordPress Dashboard.

That is not what you have mentioned in the previous replies and it gets very confusing. Previously you talked about Rest API access to translated content which is a different thing.

If you want to check with the Rest API as I mentioned I will need the code your development team used to see what happens there and maybe there is an issue when it comes to how the code is added.

I checked the backend and front end and I do see that you managed to translate the template parts correctly as I do see the Footer template part translated both on the backend and the front end.

Please check the attached screenshot.

Thank you.

Screenshot 2024-09-22 at 12.41.30.png
Screenshot 2024-09-22 at 12.39.33.png
September 25, 2024 at 8:26 am #16218938

kirily-2

Hello,

I am not really sure what exactly is confusing but I will try to clarify even more.

Teamplate parts are NOT translatable via the WordPress panel and it returns JSON error which is because the WP REST API endpoint returns 404. It is called by WordPress - nothing do to with scripts.

The template parts are translated because we are running SQL queries as our deadline to complete project is already exceeded.

I have noticed you tried to edit something and it went broken so we had to restore it - again via SQL.

So, long story short - we cannot translate Template Parts with WPML. If it's confusing, we will not point you in a direction that it might be how WPML handled the REST API endpoints - still, the problem is present.

September 25, 2024 at 12:23 pm #16220284

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for the explanation. The weird thing is that when I tried to translate the template part it still showed correctly on the front end.

So by your description, if I copy your website to our server, remove the translation, and try to do the translation again, it should not show correctly on the front end of the website as we do not run any SQL script.

To test that I wonder if I am allowed to access the website and use the cloudways plugin to copy your website to our server for further investigation?

Thanks.

September 26, 2024 at 2:00 pm #16225712

kirily-2

Hello,

We have deployed to website on production and it turns out now translations work as expected.

This means there is something with subdomain and/or sub folder websites and how the WPML handles their WP REST API url for different languages. I hope this will be of a help supporting other customers.

We can mark it as solved.

I appreciate you efforts!

Thank you so much!

September 26, 2024 at 3:17 pm #16226264

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

My name is Marcel, and I’ll be handling your ticket today as my colleague Christopher is unavailable.

Thank you for providing details about the solution to your issue. I believe the problem may be more related to rewrite rules, as WPML primarily depends on these endpoints for the REST API: https://wpml.org/documentation/support/rest-api-dependencies/.

Regular fetching of posts occurs through the standard WP REST endpoints, as shown by the different post IDs corresponding to each language version.

hidden link
hidden link

These IDs represent the translated versions of your content (pages, posts, CPTs, etc.) and are connected to the original ID from your default language.

Best regards,
Marcel

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.