This thread is resolved. Here is a description of the problem and solution.
Problem: The client wants the author bio link in the recipe card to redirect to the appropriate language version of the 'about-me' page, depending on the language the visitor is viewing the recipe card in. The current setup only redirects to the English version, even when the site is switched to Dutch.
Solution: 1. We recommend enabling the translation of the author by navigating to WPML > String Translation > More Options and checking the option to translate users. 2. If the author link is not a standard WordPress author page and is instead implemented using a custom template or page, we suggest using the wpml_object_id hook to adjust the URL based on the current language. This hook allows for the translation of post IDs, ensuring the correct page is served for each language.
3. Alternatively, you can register the URL as a string and translate it using the wpml_register_single_string hook, or create a conditional statement that checks the current language and returns the appropriate URL.
Please note that we do not provide fixes for custom code as per our support policy. If you require custom assistance beyond the scope of our support, we recommend contacting one of our certified partners from this link.
If this solution does not seem relevant to your issue, please open a new support ticket here.
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.
Tell us what you are trying to do? Have the author bio in the recipe card link to the appropriate language depending on what language the visitor is viewing the recipe card.
Is there any documentation that you are following? None that we can find.
Is there a similar example that we can see? Don't think so.
What is the link to your site? hidden link
Basically, go to any recipe in English, scroll or jump to the recipe card, then click on 'Author' (Sabine) You should be taken to the 'about-me' page. But when you switch to Dutch and click on the author bio in the recipe card it still takes you to the English version of the bio and not the Dutch version which is 'over-mij'.
I will add the first reply before this ticket is assigned to one of my colleagues.
It depends on how you implemented that author link. It does not seem to be a normal WordPress post author page and it seems to be an Elementor template.
If it is a normal Author, you can enable the author's translation by going to WordPress Dashboard > WPML > String translation > More Options and enable the translation of the users.
But for your case I am not sure.
I did a search in Google and found this article when it comes to 301 redirect and SEO impact:
Just to clarify what I've done. This is the custom code now in functions.php:
// Link author name to about page
add_filter( 'author_link', 'my_author_link' );
function my_author_link() {
return home_url( 'about-me/' );
}
And this is what's in .htaccess:
Redirect 301 /nl/about-me hidden link
The reason for doing all this is it is only a single author website. By default WordPress sends clicks on all author links at the top of posts/pages to the author archives, or the home page if you set it to with plugins like Yoast, otherwise this is apparently a duplicate content issue with single author sites.
So, we are now sending visitors to where we really want them to go, in a bit of a round about way, in that /about-me and /nl/about-me both went to the same place, hence the 301 which fixed that problem, but I have to wonder if this is something WPML can make happen by sending visitors to either /about-me or /nl/over-mij directly.
Yes, I found that setting for translating author user string translating, but that doesn't seem to help with this custom redirect.
It is a regular page made with a Divi template, which is what we've used to make every other page on the site.
I hope this clarifies things better? Or maybe the attached screenshot will show what I'm trying to fix. Look at the bottom of the image, at where they author link would take you if it wasn't for the 301:
Thanks for getting back to me. I must confess, I know what hooks are but I have never worked with them until now. I tried the one suggested after modifying as I thought I had to but it didn't work.
Also, what I am trying to do isn't very unique, it's a universal code that many use to direct the author link to a page of choice.
With that said, do you perhaps have any further suggestions on how I can get this to work to the point I will not need the 301?
Thank you for the update. One other point of clarification; as in the title, this isn't about the WP Recipe Maker plugin anymore, when I initially thought it was. It is about the Author link at the top of posts. The WP Recipe plugin gets its author link from the same place, that's the only connection.
Yes, I noticed the problem is not specific to the Recipe post type.
Here is the answer from our second-tier supporter.
Since he is using: return home_url( 'about-me/' );
He should probably add a call to localize it first.
Because his URL is "example.com/second_language/about-me," and this is calling the first language (English) page from the second language. The redirect is normal.
He can either register this as a string and translate it - using our hooks or create a simple clause first, getting the current language and returning different values by the language code.
If you show us where our hooks or API fail to work as expected, we will check and correct it if needed.
Otherwise, if you need further help with what you are trying to achieve, I would suggest you consider contacting one of our certified partners from this link:
I am marking this as not fully resolved, at least I think have enough info now to get it resolved as it would indeed seem this is now out of the scope of WPML support.