Kamrul Hasan
Kamrul Hasan

Reputation: 91

how to stay to current language while clicking a link in wpml

I am developing a multi language site with word press and wpml.

My problem is-

i have a link of a page(site.com/xyz) in a button in editor of a page which is in English. If i am in Spanish version of that page and and click that link(site.com/xyz) that goes to the English version.I want that goes to the Spanish version(site.com/es/xyz) of that page automatically instead of going to English version.(site.com/xyz).

Can anyone expert me out from it?

I hope i get some help from here. Thanks

Upvotes: 1

Views: 895

Answers (1)

Vel
Vel

Reputation: 9257

You need to use below the code for link

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


<a href="<?php echo $wpml_permalink;?>">site.com/xyz</a>

Upvotes: 1

Related Questions