Skip Navigation

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

Problem:
The client is experiencing an issue where the language switcher on the author page only displays the primary language (Dutch) and does not show the option to switch to English, despite the English version of the author page being accessible directly via its URL.
Solution:
We recommend checking if the author of the posts on the author page has their posts translated into the secondary language (English). The language switcher will only appear if the author has blog posts and they are translated. If the posts are translated and the issue persists, you may need to implement custom coding to ensure the language switcher always appears. An example of how to handle this with custom code can be found in our support forum: https://wpml.org/de/forums/topic/empty-author-archive-langauge-switch/#post-14442559.

This solution might be outdated or not applicable to your specific 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 our support forum.

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

Last updated by jaronR-2 4 months, 4 weeks ago.

Assisted by: Marcel.

Author Posts
February 6, 2025 at 12:33 pm #16675417

jaronR-2

Background of the issue:
I am trying to display a language switcher on the author page of my website, which is set to Dutch as the primary language and English as the secondary language.

The primary language author page URL is hidden link and the English language author page URL is hidden link.

I have verified that both language versions of the author page exist and have translated all strings in both languages. I also created custom fields using Advanced Custom Fields (ACF) for the user and configured the ACF Field Group with the appropriate WPML settings.

I have created author page with Elementor template. which called globally for all authors profile page.

Symptoms:
Language switcher only displays the primary language (Dutch) on the author page, and the option to switch to English is missing.

English version of the author page is accessible directly via its URL, but it is not appearing as a selectable option in the language switcher.

Questions:
Why is the language switcher not showing the option to switch to English on the author page?
How can I make the English language option appear in the language switcher on the author page?

February 6, 2025 at 5:27 pm #16676745

Marcel
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Hi,

This behavior is expected since the author archive functions as an archive rather than a regular page. As a result, custom post types (CPTs) are not included by default in the query where the language switcher is typically displayed.

You can implement this functionality using custom code. Please refer to this thread for guidance:
Language Switcher Isn't Working on Author Archive Page.

Best regards,
Marcel

February 7, 2025 at 4:17 am #16677809

jaronR-2

Hello,

In the solution provided in the thread, the issue was related to the Custom Post Type (CPT). However, we are not experiencing the issue on the CPT archive page.

Our issue is different: the language switcher is not showing the English language option on the author page.
Here is the author page link for reference: hidden link

In our site all other pages (like archive and single) are displaying the language switcher correctly with both language options, but the author page is only showing the primary language.
See the screenshot here for clarification: hidden link

February 7, 2025 at 4:30 pm #16680633

Marcel
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Hi,

I believe there was a misunderstanding in my previous response.

This is expected. The lang switcher on the author archive page will only appear if the author has blog posts + they are translated. In the profile you shared, the posts are written from another user hidden link.

1) So you can either re-assign the author of the blogs and ensure they are translated

2) Use custom coding to always show the lang switcher. There are several ways to handle this. You can see an example here:

(it's a German ticket, but the code and the initial description is documented in English:
https://wpml.org/de/forums/topic/empty-author-archive-langauge-switch/#post-14442559).

The author informations are tranlateted by string translation. This works well, if the author have posts. But if the author has no direct posts, no language switcher is shown.

In this case, the client implemented a custom function that modifies WPML’s language switcher on author archive pages, ensuring it only displays languages with a translated author description. The function retrieves active languages, checks for a translation, updates the author archive URL, and removes untranslated languages from the switcher. While this requires custom development, this example provides a useful reference to understand the approach.

Best regards,
Marcel

February 12, 2025 at 4:49 am #16694008

jaronR-2

I have solved issue with following code. Thank you.

add_filter( 'icl_ls_languages', 'mr_author_language_switch');

function mr_author_language_switch( $w_active_languages ) {

if(is_author() && count($w_active_languages) == 1) {
$user_id = get_the_author_meta('ID');
$author_url = get_author_posts_url($user_id);
$languages = apply_filters( 'wpml_active_languages', NULL, array( 'skip_missing' => 0 ) );

// Get the current active language
$current_language = ICL_LANGUAGE_CODE;

// Check current language and add the other language to the list
if ($current_language === 'nl') {
// If the current language is Dutch, add English to the language list
$languages['en'] = array(
'code' => 'en',
'id' => 1,
'native_name' => 'English',
'name' => 'English',
'major' => 1,
'active' => 0,
'default_locale' => 'en_US',
'encode_url' => 0,
'tag' => 'en',
'missing' => 0,
'translated_name' => 'Engels',
'url' => apply_filters( 'wpml_permalink', $author_url, 'en'),
'country_flag_url' => home_url() . "https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/en.svg",
'language_code' => 'en'
);
} elseif ($current_language === 'en') {
// If the current language is English, add Dutch to the language list
$eng_home_url = apply_filters( 'wpml_permalink', site_url(), 'nl');
$languages['nl'] = array(
'code' => 'nl',
'id' => 37,
'native_name' => 'Nederlands',
'name' => 'Nederlands',
'major' => 1,
'active' => 0,
'default_locale' => 'nl_NL',
'encode_url' => 0,
'tag' => 'nl',
'missing' => 0,
'translated_name' => 'Nederlands',
'url' => apply_filters( 'wpml_permalink', $author_url, 'nl'),
'country_flag_url' => $eng_home_url . "https://cdn.wpml.org/wp-content/plugins/sitepress-multilingual-cms/res/flags/nl.svg",
'language_code' => 'nl'
);
}

return $languages;
}

return $w_active_languages;
}