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 zsoltE-2 2 months, 1 week ago.

Assigned support staff: Rohan Sadanandan.

Author Posts
August 6, 2019 at 3:52 pm #4349259

zsoltE-2

I am developing a theme. There are redirects and links to different pages of the website, generated in the PHP code.

e.g.
wp_redirect( get_home_url() .'/magyaroldal/' ). This command redirects to the page named 'Magyar oldal'.

Now this 'Magyar oldal' has translation and different url :/en/hungarian-example/

What is the correct php coding the links that they will redirect to the appropriate (i.e. Hungarian or English) page?

Do you have documentation about this topic?

Regards?
Zsolt

August 6, 2019 at 5:38 pm #4349805

Rohan Sadanandan
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Thank you for contacting WPML Support.

You can use *wpml_permalink* hook for this purpose, like the following example. It will return French URL of the post.

$url = get_the_permalink();
$wpml_permalink = apply_filters( 'wpml_permalink', $url , 'fr' );

Please check this documentation for more details: https://wpml.org/wpml-hook/wpml_permalink/

Thanks,
Rohan

August 6, 2019 at 6:58 pm #4350091

zsoltE-2

Thank you. Only one question. In my case full resolution is needed?
Example from the article:
apply_filters( 'wpml_permalink', 'hidden link', 'fr', true );
This means that "/hello/" will be converted to '/fr/bonjour=' if the current page is in French?

August 7, 2019 at 5:14 am #4352095

Rohan Sadanandan
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello,

Yes, you are right. The page will be converted as you have mentioned.

Thanks,
Rohan

August 7, 2019 at 11:56 am #4354625

zsoltE-2

My issue is resolved now. Thank you!