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 Robin 2 weeks, 5 days ago.

Assigned support staff: Rohan Sadanandan.

Author Posts
September 27, 2019 at 4:09 pm #4655777

Robin

I would like the following link to change to the correct slug based upon the current language.

<strong class="uppercase"><a href="/nos-magasins">[wpml-string context="ace-denim.com" name="trouver-un-magasin"]Find a Shop[/wpml-string]</a>

When in english it should read, please see the lnk has changed:

<strong class="uppercase"><a href="/en/our-shops/">[wpml-string context="ace-denim.com" name="trouver-un-magasin"]Find a Shop[/wpml-string]</a>

hidden link

I know this is quite a simple thing but I've forgotten how to do this.

September 27, 2019 at 4:27 pm #4655901

Rohan Sadanandan
Supporter

Languages: English (English )

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

Hello,

Thank you for contacting WPML Support.

You can use the "wpml_current_language" hook for the same:

$my_current_lang = apply_filters( 'wpml_current_language', NULL );

You can read this documentation for more information: https://wpml.org/wpml-hook/wpml_current_language/

Thanks,
Rohan

September 27, 2019 at 4:58 pm #4656067

Robin

Thanks for your suggestion. May you please tell me how I could use that in a shortcode or somewhere I cannot execute PHP.

September 27, 2019 at 6:33 pm #4656371

Rohan Sadanandan
Supporter

Languages: English (English )

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

Hello,

Sorry for the inconvenience.

Currently, we don't have a shortcode for detecting the current language.
You can raise this as a feature request here: https://wpml.org/suggest-a-new-feature-for-wpml/

If you want to change the value inside a content area you can update the value in the translation.

Thanks,
Rohan

September 27, 2019 at 7:00 pm #4656439

Robin

Thanks for pointing me int he right direction. I followed the instructions here to create a 'conditional' shortcode:

https://wpml.org/forums/topic/conditional-language-shortcode/