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 1 reply, has 2 voices.

Last updated by Dražen 1 year, 8 months ago.

Assisted by: Dražen.

Author Posts
October 23, 2023 at 2:57 pm #14639583

maraM-4

$permalink = get_permalink( $pid );
$post_link = apply_filters( 'wpml_permalink', $permalink, $post_lang_code, true );

I'm trying this code but it's returning bad results (pls check attached image)

The desired result should be

hidden link
hidden link

What's wrong with my code?

wpml issue.png
October 24, 2023 at 11:54 am #14647221

Dražen
Supporter

Languages: English (English )

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

Hello,

please note as per our support policy we can not support, debug custom code or provide custom coding services.

We will be glad to help, with some advice and hopefully, that works for you, otherwise, we advise hiring WPML contractors: https://wpml.org/contractors/

Anyway, I further checked the hook for bug and similar code and it works just fine. I am not aware of your other custom code and setup, but it could be you are not getting the correct language code or Post ID or some other parts causing issues.

We advise using wpml_current_language hook:

- https://wpml.org/faq/how-to-get-current-language-with-wpml/

You can check my results in the footer of the next test website: hidden link

Code used: https://pastebin.com/raw/6BXDk6zN

Hope this helps and please note it is just an example code and to be further adjusted and managed for your case by the developer.

Regards,
Drazen