Skip to content Skip to sidebar

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 3 replies, has 0 voices.

Last updated by Bruno Kos 1 week ago.

Assisted by: Bruno Kos.

Author Posts
July 7, 2025 at 5:38 am #17206059

desireeM

Background of the issue:
I am trying to use get_site_url() to return the URL in the default language, as it did in previous versions. Previously, get_home_url() returned the URL in the current language, while get_site_url() always returned the URL in the 'default' language. This behavior seems to have changed.

Symptoms:
get_site_url() now returns the URL in the current language instead of the default language.

Questions:
Why does get_site_url() return the URL in the current language instead of the default language?
Has there been a change in the behavior of get_site_url() in recent versions?

July 8, 2025 at 6:57 am #17211928

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

To help us investigate this further, could you please show exactly where the issue occurs on your site? Specifically, we’d like to understand what isn’t working as expected and under what conditions.

This will help us determine whether it’s a compatibility issue with a third-party plugin or theme, or if it might be a bug in our own code that needs to be escalated.

July 8, 2025 at 10:08 pm #17216255

desireeM

You already provided the reproducer yourself? So what exactly is unclear?

The main issue is that you changed this behavior without mentioning this anywhere.

e.g. woocommerce paypal payments used the site_url to generate an invoice prefix. Now suddenly the invoice prefixes are different.
woocommerce-subscriptions uses the site_url for various things, which now suddenly broke some subscriptions if they were created on a translated page,...

Making site_url per language makes sense (and was the right decision to finally change that), however there must be a mention of that somewhere. Bc that change caused tons of unexpected behaviors in various plugins.

So please don't change it back now, just mention it in the changelog at least.

July 9, 2025 at 8:39 am #17217654

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

I checked with our developers, and we found a relevant note in the WPML changelog:
https://wpml.org/changelog/2016/11/wpml-3-6-translation-page-builders-new-language-switcher-wp-4-7-compatibility/

Fixed a compatibility issue with get_option(‘siteurl’) in sites with languages set as domain

It refers to a fix for a compatibility issue with `get_option('siteurl')` in sites using separate domains per language. While the changelog entry isn't very detailed, it aligns with what we're seeing in the code.

Specifically, the behavior seems to stem from this block:

if ( ! $this->debug_backtrace->is_function_in_call_stack( 'get_home_path', false ) && ! $getting_network_site_url ) {
    $parsed_url = wpml_parse_url( $url );
    $host       = is_array( $parsed_url ) && isset( $parsed_url['host'] );
    if ( $host && isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] ) {
        $domain_from_global = $this->get_host_from_HTTP_HOST();
        if ( $domain_from_global ) {
            $url = str_replace( $parsed_url['host'], $domain_from_global, $url );
        }
    }
}

This part of the logic attempts to override the host in the URL under certain conditions, which could affect how `get_site_url()` behaves when domains are language-specific.