Skip Navigation

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

Problem:

Using get_option('siteurl') returns the default language URL and not the URL of the current language

Solution:

Please use get_option( 'home' ) instead. Check the documentation for more information.

Relevant Documentation:

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

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 christosM-5 2 years, 10 months ago.

Assisted by: Christopher Amirian.

Author Posts
June 19, 2022 at 11:03 pm #11493819

christosM-5

Hello,
my theme (Citadela-Ait-themes.club) depents on the function get_option('siteurl') to read the site url and validate/verify the install through an ajax call to their server and a response.
I have used the wpml option to have different domains per language
Default/registered url --> hidden link
Italian version --> hidden link
English version --> hidden link
It seems that the above function returns the language domain url when someone visits the other language versions e.g Italian url(hidden link) instead of the default language wordpress site url (hidden link) which is registered for the theme and when this happens the theme brakes because karag.it is not registered
I checked it by using <?php echo get_option('siteurl') ?> in functions.php and the url that prints is the language domain url My client wants to keep the different domains per language Any ideas how can I deal with this problem?

June 20, 2022 at 6:21 am #11495395

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

That is the appropriate behavior for the separate domain mode. The whole reason for the separate domain is to make sure WP thinks of it as a separate domain and in the other language points to the domain that you set in WPML > Languages.

Now what I have in mind to replace the code with:

get_option( 'home' )

See if it helps?

If not you will need to use the WPML hook to determine the default language URL by determining what is the default language and get the equivalent URL of that language:

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

Thanks.

June 20, 2022 at 8:26 pm #11502637

christosM-5

Hi Christofer,
thanks for clarifying this. If I only realized this earlier it would have save me days of troubleshooting
I already use the get_option('home') as a workaround and I have suggested this solution to the theme developers as to be a permanent change in their code I hope they will be conviced to do it so I dont have to manually do it in every theme update
Thank you