Home›Support›English Support›[Resolved] The language switcher only displays the default language on the author's profile
[Resolved] The language switcher only displays the default language on the author's profile
This thread is resolved. Here is a description of the problem and solution.
Problem: If you're experiencing an issue where the language switcher only shows the default language on author profiles, even when there are no posts or other information translated into all languages, we have a solution for you. Solution: Firstly, ensure that the translation preference for Posts is set to display the default language when a translation is not available. You can do this by navigating to WPML > Settings > Post Type Translation and adjusting the setting for "Posts" to "Translatable - use translation if available or fallback to default language".
Alternatively, you can use a custom code approach. We've provided a code snippet that you can add to your theme's
functions.php
file. This code will adjust the Language Switcher on the Author page to show additional languages, regardless of whether the author's posts have been translated.
If this solution doesn't seem relevant to your situation, please don't hesitate to open a new support ticket with us for personalized assistance. You can do so by visiting 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.
On my website I display a list of all registered users and all people have access to their profiles. The problem is that the language switcher only shows the default language. I am using the WordPress full site editor.
Actually the page is already translated properly, the problem is that only one of the two languages is displayed in the language switcher.
For example, if I go to /author/prueba/ it shows me the author's page in Portuguese, but it doesn't give me the possibility to change the language in the language switcher. The same happens if I enter /en/author/prueba/, in this case it shows me the translatable information in English but I don't have the possibility to change the language.
Please note that the language switcher is designed to display and function correctly for Authors who have posts that are translated into other available languages. If an author hasn't posted anything or has only posted in one language, the language switcher will not appear on that Author's profile.
However, if you wish for the Language switcher to display languages and function correctly irrespective of whether the author's post has been translated or not, you can try the suggestion mentioned in the response below.
Please note that ticket visibility is restricted to logged-in users only. Make sure you are logged into your WPML.ORG account to view them. I can confirm that the ticket is not marked as private.
Let me know the update. I will be happy to help if you need further assistance in this matter.
I'm sorry if my earlier message seemed dismissive or disrespectful - that was not my intention. I didn't mean to question your intelligence or your grasp of the situation. The suggestion to check by logging into your account was based on the common practice of many users attempting to access links directly from their emails. I hope you can understand.
Since you can't access the ticket, I've included the particular response below.
The Language Switcher should only display other languages in the Author template if the Author has a post that has been translated into those languages. If the post is not translated, even the default language will not appear in the language switcher.
Now, this can be solved in two ways:
1) Setting up the translation preference for the Posts to display the default in case the translation is not available: Please navigate to WPML > Settings > Post Type Translation. Here, adjust the translation preference for "Posts" to "Translatable - use translation if available or fallback to default language". This setting ensures that the default language post is shown when a translation is absent, allowing the language switcher to consistently display alternative languages on both the post and author pages. This method is recommended.
2) Code Approach: Using WPML's hooks and filters, you can adjust the Language Switcher on the Author page to show additional languages, regardless of whether the author's posts have been translated into those languages.
While our support platform typically doesn't assist with custom coding, I'm providing you with a code snippet. This code is designed to hide languages in the language switcher on an Author's page if they haven't published any posts. The languages will be displayed only if the Author has at least one post, regardless of whether the post is translated or not.
Please copy the code from here[ hidden link ] and past it in the functions.php file.
If you're using this code, make sure that a description is added in the Author Profile(you can add that by going to Users > Profile → About the user → Biographical Info), and the description is also been translated.
If you need further assistance with the custom code, you can hire a contractor specialized in customizing WPML, from here: https://wpml.org/contractors/
I hope it helps. Please let me know if you need further assistance in this matter. I will be happy to help.
By itself it serves someone in the future, to always show the active languages in the authors' profiles, regardless of there is no post or any other information translated to all languages, the code can be the following.