Skip Navigation

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

Problem:
The client is experiencing incorrect URL redirection when switching languages using the dropdown flag on the front page of their multilingual website. The URLs are pointing to album pages instead of the homepage in different languages.
Solution:
We realized that the theme's Customizer was using a different frontpage setting. Ensure that the theme's Customizer settings for the front page are correctly configured. In this specific case the issue might be due to the front page being set to a 'Single Album' which could confuse URL redirection. Changing this setting to a static page like 'Homepage' might resolve the issue.

If these steps do not resolve the problem or if the solution seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum for further assistance.

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.

Our next available supporter will start replying to tickets in about 11.63 hours from now. Thank you for your understanding.

This topic contains 8 replies, has 2 voices.

Last updated by Andreas W. 1 month, 2 weeks ago.

Assisted by: Andreas W..

Author Posts
September 27, 2024 at 12:05 am #16227744

robertoB-80

<b>Background of the issue: </b>
In my site, I have 3 languages: Croatian (default) at hidden link, English at hidden link, and German at hidden link. The front page structure includes a photo album and a static page set in WP settings. I am using WPML for language switching.

<b>Symptoms: </b>
When I click the dropdown flag to change the language on the front page, the URL is incorrect. For example, for English, the URL is hidden link instead of hidden link. The same issue occurs for the default language.

<b>Questions: </b>
How can I fix the URL issue when switching languages using the dropdown flag on the front page?

September 27, 2024 at 6:42 am #16228241

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I can see even the same issue when switching to German or Croatian.

hidden link
hidden link

Revising the source code it looks as if the site is using hardcoded links, that are placed directly inside the theme instead of using the WPML Language Switcher.

Usually, this might be a topic for the theme developer. WPML's Custom Language Switcher needs to be included in the Header template of the theme by calling:

 do_action('wpml_add_language_selector');

Example::
https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/

To confirm that WPML handles the redirections correctly, you can go to WPML > Languages and enable WPML's Footer Language Switcher.

Let me know if this switcher works as expected.

Best regards
Andreas

September 27, 2024 at 11:26 am #16229616

robertoB-80

I enable Footer language switcher, but cannot see switcher in footer.
Also try add menu in Main menu and problem is still here.
Try Add widget in footer and url is still wrong

September 27, 2024 at 5:37 pm #16230991

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Thank you for your message!

I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the website to investigate this issue further.

You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it.

IMPORTANT
Please be sure to make a backup copy of the website and database before allowing us access.
If you can't see the wp-admin / FTP fields, your post and website credentials are set as PUBLIC. DO NOT publish the data unless you see the required wp-admin / FTP fields.

I may have to install a plugin called "All In One WP Migration" to make a copy of the website where I can investigate the issue further.

However, I would also be very grateful if you could provide a staging site or copy of the website from your server yourself for this purpose. This step would only be required if the issue is replicable on such a staging site.

If you have any questions about creating such a staging site, you can consult your hosting provider. Just take note that WPML should be registered on this site again.

If you are unable to provide such a copy of the site for testing, please let me know on this ticket.

The private response form looks like this:
hidden link

Next time you reply, click "I still need assistance."

Video:
hidden link

Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form.

September 30, 2024 at 6:40 pm #16237453

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

I used the menu language switcher for testing and can confirm the same issue here.

Do you agree if I install the plugin "All In One WP Migration" to take a copy of the site to investigate this issue further?

September 30, 2024 at 9:10 pm #16237660

robertoB-80

Hi,

Yes

October 1, 2024 at 3:59 am #16238173

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Thank you!

I have taken a local copy and I can confirm that the issue persists while testing the site only with the Apollo13 Framework Extensions plugin.

What is kind of odd, is that inside the theme's Customizer, the Frontpage is set to a "Single Album" and this seems to be the reason why WPML is confusing the URL:

If I change the setting, the redirection seems to work, for example when being on the Blog page.

This looks to me like an issue for the theme support.

frontpage single album.jpg
October 1, 2024 at 4:40 am #16238216

robertoB-80

Thanks. I have problem and with link rel="alternate" hreflang="hr" (en,de) but that resolve with this wp function

// Promjena alternate URL-ova u ispravne
function customize_wpml_hreflangs( $hreflangs ) {
// Promijenite URL za hrvatski jezik
if ( isset( $hreflangs['hr'] ) && strpos( $hreflangs['hr'], '/album/naslovni-album/' ) !== false ) {
$hreflangs['hr'] = 'hidden link';
}

// Promijenite URL za engleski jezik
if ( isset( $hreflangs['en'] ) && strpos( $hreflangs['en'], '/album/title-album/' ) !== false ) {
$hreflangs['en'] = 'hidden link';
}

// Promijenite URL za njemački jezik
if ( isset( $hreflangs['de'] ) && strpos( $hreflangs['de'], '/album/titelalbum/' ) !== false ) {
$hreflangs['de'] = 'hidden link';
}

// Promijenite x-default
if ( isset( $hreflangs['x-default'] ) && strpos( $hreflangs['x-default'], '/album/naslovni-album/' ) !== false ) {
$hreflangs['x-default'] = 'hidden link';
}

return $hreflangs;
}
add_filter( 'wpml_hreflangs', 'customize_wpml_hreflangs' );

October 1, 2024 at 4:56 am #16238228

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

As mentioned in my last comment, the issue is caused inside the Theme's Customizer when setting the Frontend setting.

I can see this issue even when WPML is disabled. The Frontpage is set to "Single Album" inside the Customizer (Theme Options) while WordPress uses a static page "Homepage".

Best regards
Andreas

static page.jpg
frontpage.jpg