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 Waqas Bin Hasan 1 year, 10 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
August 7, 2023 at 10:02 pm #14166247

quentinO

Dear team,

It looks like the custom route created does not work properly, it looks like a cache problem because it does work sometimes. The data fetched by the API shows perlmalink in the wrong language.

I dont have this problem for me others custom post but only when using the API

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

for your information in my route i;m using the if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
$permalink = apply_filters( 'wpml_permalink', $permalink , $lang);
}

i debugged and found nothing and i logged the $lang that i recieve as a parameter from the fetch and this $lang is correct (en or pt)

i can reproduce this error locally with a generatepress theme and no other pluggins than wpml and no cache,

Really need your help im stuck on that

Thank you
Quentin

August 7, 2023 at 10:15 pm #14166253

quentinO

Ive noticed that it depends on the language selected by the user, it will fetch the permalink only in the selected language of the user. When i reset the user language it works again but once the user will switch language it starts mixing. For exemple i set the language to PT then he logs in and switch to EN by error but then comes back to a EN page in this case he cannot come back to PT and well only see EN content even though he is on a PT page. Best

August 8, 2023 at 12:28 pm #14169223

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Quentin,

Thank you for contacting the support.

I just checked the URL you mentioned in your first message and could see it working fine. I used language switcher to switch between EN and PT, see the screencast hidden link.

However, can you please explain in more details that how you are creating custom routes and how you are using the API?

Please note that custom coding is out of scope of this forum but I can only review and see if I can help in this matter.

Regards.

August 8, 2023 at 2:07 pm #14169797

quentinO

Hi Waqas;

Yes it's working well on all site but not when i use it with the API. Like for this : hidden link where my custom post does not fetch the good language properly.

It's custom code but i want to use a standard features that your are selling (With WPML, you can translate custom post types, custom fields...)

Thank you,
Quentin

August 9, 2023 at 9:10 am #14174035

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

WPML offers filters and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse following resources for more information:

- https://wpml.org/documentation/support/wpml-coding-api/
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
- https://wpml.org/documentation/support/wpml-coding-api/shortcodes/
- https://wpml.org/faq/how-to-get-current-language-with-wpml/
- https://wpml.org/documentation/support/wpml-tables/
- https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/
- https://wpml.org/documentation/support/

If you need additional custom work, we recommend you contact WPML Contractors at https://wpml.org/contractors/.