This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing issues with author pages redirecting to the homepage instead of displaying the correct author page in various languages. This occurs when there are no posts available in the requested language.
Solution: This is the theme-specific issue that was not replicable on a new test site. We recommend using a custom code snippet to modify the behavior of the WPML language switcher on author pages. This code ensures that the language switcher links directly to the author pages, even if there are no posts in that language, thus preventing redirection to the homepage.
add_filter( 'icl_ls_languages', 'wpml_author_switcher_fix', 10, 1 );
function wpml_author_switcher_fix( $languages ) {
if ( is_author() ) {
$author = get_queried_object();
$author_slug = $author->user_nicename;
$default_lang = apply_filters( 'wpml_default_language', null );
foreach ( $languages as $lang_code => &$lang ) {
if ( $lang_code === $default_lang ) {
// No language prefix for default language
$lang['url'] = '/author/' . $author_slug . '/';
} else {
$lang['url'] = '/' . $lang_code . '/author/' . $author_slug . '/';
}
}
}
return $languages;
}
Please note that 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 WPML 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.
Background of the issue:
I am trying to translate an author page on my website. Here is a customer/author: hidden link. I want the page to display correctly in different languages. It works in Arabic: hidden link, but for other languages, it redirects to the homepage instead of the correct author page, such as hidden link and hidden link. The issue can be seen here: hidden link.
Symptoms:
When I try to navigate the author page based on language, it sometimes redirects to the homepage instead of the correct author page. I expected it to show news based on the author's language, but instead, I got redirected to the homepage.
Questions:
Why does the author page redirect to the homepage for certain languages?
How can I ensure the author page displays correctly in all languages?
While you wait for my colleague to take over the ticket, let me try to help you with the issue quickly.
Make sure post exist for that language for that author, if there is no post in EN then WordPress does not create author page. In short, make sure you have translated posts from this author to other languages also.
I just wanted to ensure
if user has any posts then it show as usual : hidden link
if user doesn't have any posts, It should show like that: hidden link
"Opps nothing here...."
My question is- why it not works for other language ?
hidden link hidden link hidden link
I have many user who has only english article and will not have translated of them. and I manage my business like that if they want to translate they need to pay so most of the client has on language posts
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
I created a test site using the Twenty Twenty-One Theme and WPML, and I can not confirm this issue.
In my example, the site's default language is English, and I have one post in German.
If I revise the author page in German, I see one post as expected, and there is no language switcher option, as the English author page has no posts: hidden link
This means, on your site, it is unexpected that the WPML languages switcher offers a language option if the translated author page has no posts.
My test page: hidden link
Now, the unexpected behavior on your site could be caused by the theme or by custom code used in your child theme.
Could you please install the latest version of the Foxiz Theme on the following test site, so that we can test if this issue if theme-related?
One-Click-Login: hidden link
Leave me a comment on this ticket once you are done with this task.
I have few custom code on child theme and wp code plugin but they are not even related to wpml .
Even I have tested by remove my child theme code and decativate custom code plugin.
this didn't make any solution,
Please keep in mind, I have enabled this option:
-How to handle languages without translation :
Link to home of language for missing translations
may be that's why It redirect home page if user doesn't exist any posts but it should work for all user.
my concern is here :
it should behave one consistent way:
Either the author page generate for all user, if author doesn't have any posts then it shows: hidden link
or Shouldn't generate author page who doesn't have any posts.
but here behaves unusual:
if user doesn't have any posts, It should show like that: hidden link
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Would it be possible for you to install the latest version of the Foxiz Theme on my sandbox, so that we can try to replicate the issue there and then take further steps?
One-Click-Login: hidden link
If this is not possible, I can offer to take a closer look at your site as an admin user.
You can find the required fields below the comments section when you log in to leave the next reply. The information you provide is private, meaning only you and I can see and access it.
IMPORTANT
Please be sure to back up your website and database before granting us access.
If you can't see the "wp-admin / FTP" fields, your post and website credentials will be set to "PUBLIC." DO NOT publish the data unless you see the required wp-admin / FTP fields.
I may need to install a plugin called "All In One WP Migration" to create a copy of the website so I can investigate the issue further.
However, I would also be very grateful if you could provide a staging site or a copy of the website from your server for this purpose.
If you have any questions about creating such a staging site, you can consult your hosting provider. Please note that WPML must also be registered on this staging site at https://wpml.org/account/websites/.
If you are unable to provide such a copy of the website for testing, please let me know on this ticket.
The private reply form looks like this: hidden link
Click "I still need assistance" the next time you reply.
Video: hidden link
Please note that we are required to request this information individually on each ticket. We are not permitted to access any credentials that were not specifically submitted on this ticket in the private response form.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
My apologies for the delay in answering.
As I mentioned earlier, on my test site, WPML will not display language options inside the language switcher if an author page has no posts.
In your case, you see a language option, as at WPML > Settings > Post Types Translation, the type "Posts" is set to "Translatable use translation if available or fallback to default language".
Your example author only has one post in Arabic: hidden link
If I now use the language switcher on this page to switch to another language, I will always land on the respective homepage.
This is expected as long as the archive has no posts.