Skip Navigation

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.

This topic contains 9 replies, has 2 voices.

Last updated by Waqas Bin Hasan 4 months, 2 weeks ago.

Assisted by: Waqas Bin Hasan.

Author Posts
July 1, 2024 at 10:15 am

attilioC-2

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?

July 1, 2024 at 11:05 am
July 1, 2024 at 11:06 am #15868027

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

Regards.

July 1, 2024 at 11:09 am
July 1, 2024 at 1:00 pm #15868716

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the access, I was able to login.

I am looking into this and 'll get back to you accordingly.

July 1, 2024 at 5:50 pm #15870082

attilioC-2

The example article with the tags configured is as follows
hidden link

July 2, 2024 at 7:22 am #15873072

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

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.

Screenshot 2024-07-02 121628.jpg
Screenshot 2024-07-02 121539.jpg
Screenshot 2024-07-02 121507.jpg
Screenshot 2024-07-02 121311.jpg
July 2, 2024 at 11:15 am #15874633

attilioC-2

I thank you for the valuable analysis.
You have not modified any files?
Can I proceed with the BK reset?

July 2, 2024 at 12:28 pm #15875161

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

No, I didn't modify any file, except the template-parts/single.php to add some echo and print_r statements, which I guess I removed later on.

July 2, 2024 at 3:42 pm #15876721

attilioC-2

Thank you for your efficient assistance

July 2, 2024 at 7:16 pm #15877790

attilioC-2

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.

Thank you in advance

seconda.png
prima.png
July 3, 2024 at 7:25 am #15881528

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the details.

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.