[Resolved] Translations for tags in the second language are not displayed
This thread is resolved. Here is a description of the problem and solution.
Problem: The client has created a field with ACF called Tags, which is a taxonomy for tags matched to images attached to posts. Although these tags are translated, they are not displayed in the Italian version of the site.
Solution: We found that due to some custom coding the issue arises because when media is added in the default language and tagged, the tags are stored in the postmeta table. However, when switching to the secondary language and editing the media, the translated tags do not have a corresponding entry in the postmeta table. To resolve this, the client should edit the media in the secondary language, remove any pre-filled tags, and add them again to ensure the postmeta table is updated correctly for the secondary language.
If this solution does not resolve your issue, or if it seems outdated, we recommend opening a new support ticket. Additionally, 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. For further assistance, please visit our support forum 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 have created with ACF a field called Tags of type taxonomy tags nume field tags translation preferences translate taxonomy tags locations rules attached, which is matched to all the images attached to the post. The site has two languages, the main one being English and Italian. The problem is that although the tags are translated, they are not displayed in the Italian version. I have checked the DB and there is a correspondence between the English tags and the Italian tags.
Symptoms:
In the English version, the tags are displayed correctly: hidden link. They are not displayed in the Italian version: hidden link.
Questions:
Why are the translated tags not displayed in the Italian version?
How can I ensure that the tags are displayed correctly in both languages?
Reference to our recent chat, I need to take a closer look at your site. So I request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.
Your next answer will be private, to share this information safely.
Also provide detailed steps to reproduce the issue and links to pages in admin and on frontend.
IMPORTANT: Please take a complete backup of the site to avoid data loss. I may need to activate/deactivate plugins also.
I analyzed the issue in much detail and found that the code you're using is fine.
The problem is when a tag (or taxonomy) is added to a post type (i.e. media is post_type = "attachment"), an entry is added in postmeta table (i.e. meta_key "tags" with related values).
Since you add media in default language and then assign some tags, this works fine.
However, if you switch to secondary language and edit the media, you may notice for some media, the tag is pre-filled with its translated version (provided that the tag has been translated). BUT, in database there's no postmeta entry for this version of media.
To fix this, all you need to edit the media in secondary language, remove any existing visible tag if any, and add the tag(s) again. So the postmeta table entry for the attached tags is created for secondary language media also.
On this post hidden link, I've tried this with a few images and have left one as it is, as a proof of concept, please see attached.
Hi,
I tried inserting renamed images from scratch. but I notice that there are tags that are duplicated in Italian, as you can see in the attached images, as a family.
If I try to delete the family tag it remains visible even if only once. Although it is not included in the tags. This also happens with other tags, I have tried on several images. Whereas in the English version everything works correctly.
It is as if WPML does not delete some tags but leaves them attached to the image even though they are no longer configured on it.
Another problem, always in Italian, if I try to insert the tag "musica" it doesn't find it, but if I try to create it it tells me that it already exists.
I observed these issue in your site and also noticed that when you remove a tag, it is removed from the database but stays on frontend. So when you add the same tag again, it starts duplicating.
I've also tried clearing caches and troubleshooting options but looks like it needs detailed investigation.
Since this issue is different than the originally reported in this ticket, I recommend opening a separate ticket because as per forum policy we can only handle one issue per ticket. So you can get more to the point help, without mixing up several issues in one long ticket.