This thread is resolved. Here is a description of the problem and solution.
Problem:
You are experiencing issues with displaying translated taxonomy terms attached to a custom post type using the function
get_the_terms()
. The terms always appear in the default language, and the
$current_ID
variable returns nothing, which prevents displaying links to the translated taxonomy terms.
Solution:
First, ensure that your code functions correctly in the default language. If it does, the issue might be related to how the translations and taxonomy terms are set up in WPML. Here are the steps we recommend:
1. Verify that each post and its corresponding taxonomy terms are translated into the desired languages.
2. In the WPML settings, configure your custom post type (CPT) and taxonomy to be 'Translatable - only show translated items'.
3. Check if the issue persists using a default WordPress theme, as custom themes can sometimes cause conflicts.
If these steps do not resolve the issue, it might be due to outdated methods or incompatibilities with your current setup. 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 problem continues, please open a new support ticket with us for further assistance 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.
Tagged: Custom Work
This topic contains 15 replies, has 2 voices.
Last updated by Dražen Duvnjak 3 weeks, 6 days ago.
Assisted by: Dražen Duvnjak.
Author | Posts |
---|---|
October 30, 2024 at 8:02 am #16345088 | |
tanaS |
Background of the issue: : I want to display a link to the translated term and translated name, but this always shows the name and link in the default language. I have used wpml_object_id and wpml_element_link filters without success. Printing $current_ID variable returns nothing. I also tried to get the current post id via $post->ID with the same result. get_the_ID works normally and shows the current post id. Symptoms: Questions: |
October 30, 2024 at 8:30 am #16345244 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
hello, since it is taking a while let's continue with the ticket, and I will also need time to debug. You can let me know here when it is ready and what code you add where. Regards, |
October 30, 2024 at 8:31 am #16345254 | |
tanaS |
Reopen this thread again !!!!! |
October 30, 2024 at 8:33 am #16345261 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, it is open, this is a ticket, you can let me know when ready and what have you done and I will check it out further 🙂 Regards, |
October 30, 2024 at 8:33 am #16345290 | |
tanaS |
I have registered new CPT and custom taxonomy, created test post and test taxonomy term and attached it to post. Check for that. Edit: i also created single-inzerat.php file with all code here: hidden link |
October 30, 2024 at 8:35 am #16345307 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, sure, can you let me know what custom code you have added and to which files, so I know what to check? Thanks, |
October 30, 2024 at 8:37 am #16345341 | |
tanaS |
hidden link |
October 30, 2024 at 8:41 am #16345378 | |
tanaS |
Line 123 |
October 30, 2024 at 8:48 am #16345387 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, thanks. How can I see the issue on the frontend, what page should I visit? Also, I see posts are not translatable and translated, they need to otherwise they do not have language information and are not associated with categories in those languages. Regards, |
October 30, 2024 at 9:09 am #16345494 | |
tanaS |
Sorry, CPT posts are set as translatable for now. Please check file: and post: |
October 30, 2024 at 9:22 am #16345585 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, Thanks, but I really have trouble understanding the issue. 1) I am checking you SK post, but I do not see category showing there and you code working also? Also post need to be translated and existing in EN, so I have translated it. Can you please make sure the code is working in the default language and then I can check why is not working in 2nd language? 2) Also if possible, please try to show the issue with WP default theme, as I see you have now added your custom coded theme, and we can not debug or support such a thing. We would be glad to help, but we can not debug issue with the whole custom theme. Let me know. Thanks, |
October 30, 2024 at 9:25 am #16345643 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, okay, I see you have not assigned them or reproduced the issue fully. I have done it now and I can see it works fine, what I have done is translated the post to EN and from WPML > Settings set for CPT and taxonomy to "Translatable only show translated items". Please check: hidden link Regards, |
October 30, 2024 at 9:37 am #16345691 | |
tanaS |
It looks like problem with taxonomy term on my website, because, on sandbox site if i switch language to english, it shows translated term, but it doesn't work on my site, as You can see on screenshots (after Category:) |
October 30, 2024 at 9:50 am #16345777 | |
tanaS |
I think, I understand this problem for now. Posts need to be reproduced like SK version, EN version and assign right category terms to each of them... but if my client wants to not reproduce post to all languages? If he wants to create only one version of post for all languages? Then is needed to assign post to both categories SK and EN to work correctly when switching language? |
October 30, 2024 at 9:50 am #16345779 | |
Dražen Duvnjak Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, Can you please also check that you have done the same on your website and have translated the post and set CPT and related taxonomy to option "Translatable only show translated items"? Thanks, |