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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-08:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Bobby 1 year, 1 month ago.

Assisted by: Bobby.

Author Posts
January 24, 2024 at 4:50 pm #15222986

jamesG-38

Hi, I need to lookup the category slug in English (while WPML is set to another language on the front end).

$translated_taxonomy_slug = apply_filters( 'wpml_get_translated_slug', $category->slug, 'category' ,'en', 'taxonomy' );

January 24, 2024 at 10:46 pm #15224147

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi,

Please review the documentation shared by my colleague here:
https://wpml.org/wpml-hook/wpml_get_translated_slug/

Let me know your results

January 25, 2024 at 7:05 am #15224576

jamesG-38

Hi Bobby, the reason I raised this issue is that even though I have already followed the documentation you again refer me to, I have tried various combinations of this and it does not work. Refer attached 2 images related to the below.

1. Code using the standard PAGE post and FR category slug does NOT return he EN slug as it should.
2. Instead this code returns the FR slug, which I already have. The page is here - hidden link

This should just work in my view. So what is wrong here?

Thanks in advance. James

Screenshot 2024-01-25 at 08.05.29.png
Screenshot 2024-01-25 at 08.05.21.png
January 26, 2024 at 8:26 pm #15231667

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for sharing the screenshot!

When I visit the page in French and click on Find Sessions for "Therapies Corporelles" it is taking me to EN. Are you currently using a redirect for this URL?

As an alternative to custom code I wonder, what are your results if you use WPML Sticky Links along with these steps from our documentation

https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language

The topic ‘[Closed] Custom code for finding translated slug’ is closed to new replies.