Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem: How can I get the Language URL format in use in php?

Solution: We can use the following code to get the Language URL format. The *wpml_setting* API call will return 1 if the Language URL format option is *Different languages in directories* and 3 if the option is *Language name added as a parameter*.

$is_wpml_configured = apply_filters( 'wpml_setting', 0, 'language_negotiation_type' );

Relevant Documentation: https://wpml.org/wpml-hook/wpml_setting/

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.

This topic contains 2 replies, has 2 voices.

Last updated by carlosS-40 4 years, 12 months ago.

Assisted by: Bigul.

Author Posts
April 26, 2019 at 6:51 pm #3692867

carlosS-40

Tell us what you are trying to do?
I need to know in php code the WPML language format currently in use for a given site in multisite environment.

/?lang=en versus /en/

I know I can decipher the url but would be nice if there is a function or constant that already defines what format is currently in use.

THanks

April 29, 2019 at 9:26 am #3701567

Bigul
Supporter

Languages: English (English )

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

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve these issues.

Please use the following code to get the Language URL format using PHP.

$is_wpml_configured = apply_filters( 'wpml_setting', 0, 'language_negotiation_type' );

The *wpml_setting* API call will return 1 if the option is *Different languages in directories* and 3 if the option is *Language name added as a parameter*.

Please check the following documentation for more details and let me know your feedback.

https://wpml.org/wpml-hook/wpml_setting/

--
Thanks!

Bigul

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.