This thread is resolved. Here is a description of the problem and solution.
Problem:
You are unable to display the FSE template for one specific taxonomy term in the secondary language on your site, while other terms display their templates correctly.
Solution:
We corrected a mistake in the function we initially shared with you. Here is the updated function that you should use:
function wpmlsupp_10867( $templates ) {<br /> if ( current_theme_supports( 'block-templates' ) ) {<br /> $current_term = get_queried_object();<br /><br /> do_action( 'wpml_switch_language', apply_filters( 'wpml_default_language', null ) );<br /> $original_term = get_term($current_term->term_id);<br /> do_action( 'wpml_switch_language', null );<br /><br /> if (isset($original_term->slug) && $original_term->slug !== $current_term->slug ) {<br /> array_unshift($templates, 'taxonomy-' + $original_term->taxonomy + '-' + $original_term->slug); <br /> }<br /> }<br /><br /> return $templates;<br />}<br />add_filter('taxonomy_template_hierarchy', 'wpmlsupp_10867');
Please replace the previous code with this corrected version. Additionally, we noticed that the term-specific template might not be added correctly from the backend. Could you please inform us about the tools or methods you are using to add the term template?
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your 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 further assistance is needed, 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.
Tagged: Exception
This topic contains 24 replies, has 2 voices.
Last updated by Itamar 1 year, 5 months ago.
Assisted by: Itamar.
Author | Posts |
---|---|
June 23, 2023 at 1:41 pm | |
alexanderC-32 |
I can't get one of my taxonomy term's FSE template to display on the frontend for my secondary language. All other terms are displaying their appropriate templates, excerpt for one. |
June 23, 2023 at 2:42 pm | |
June 25, 2023 at 12:50 pm #13890697 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, I'll continue to help you with this issue. Can you please confirm that the problem in the French translation is that the names and dates are showing underneath the image? Please see the attached screenshot berries-french.jpg. Also, can you please confirm that the 'Other species' section is missing in French? Please explain to me which ACF field groups and which templates and template parts are involved in creating this archive view. Thanks, |
June 26, 2023 at 12:24 pm #13895149 | |
alexanderC-32 |
Hi Itamar, Thanks for the continued assistance. Yes, the problem is the on the french translation, that template should be like the one that's displaying for the Flowers archive page (screenshot attached). And yes, the Other Species section is missing, but I believe that's just because the proper template is not being loaded on the French side, based on it displaying that different layout. I have created a taxonomy term template for each species term. The template for berries is called Species: Berries in English, and Species: Baies in French. The template parts used for the template are Header and Footer. Although I've been trying to sort out another issue I'm getting with the footer, so it may not show on every template. There are no ACF field groups that are directly being used in the taxonomy term template. The template is simply grabbing the featured image and title of those posts, to display on the archive pages for all. |
June 26, 2023 at 1:25 pm #13895727 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, and thanks for the detailed explanation. I'm consulting our second-tier supporters about this issue. I'll update you here once I have further news regarding this issue. I appreciate your patience. |
June 28, 2023 at 1:13 pm #13910373 | |
alexanderC-32 |
Hi Itamar, Do you have any update on the issue? Thanks. |
June 28, 2023 at 4:45 pm #13912381 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, Sorry, not yet. I've sent a reminder notice to our second-tier supporter. I'll keep you updated. Thank you for your patience. |
July 2, 2023 at 8:20 am #13928681 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, Our second-tier supporter still debugs this issue but found a workaround that fixes it. If you go to Plants -> Species and switch to French, you can quick-edit the "Baies" term. There you should change the lug from "baie" to "berry" and press the Update Species button. Please see the attached screenshot baie-to-berry.jpg. Then the template will be OK. I did this change on your site, and it is OK. Please see the attached screenshot template-ok.jpg. I'll keep you updated on any news regarding this issue. Thank you for your patience. |
July 4, 2023 at 7:38 pm #13944695 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, Our second-tier supporter found a better workaround than the above. Please discard the previous workaround and apply the following workaround. 1. Take a backup of your site in case something goes wrong. 2. Edit the functions.php file of your them with a code editor. 3. Add the following function. function wpmlsupp_10867( $templates ) { if ( current_theme_supports( 'block-templates' ) ) { $current_term = get_queried_object(); do_action( 'wpml_switch_language', apply_filters( 'wpml_default_language', null ) ); $orignal_term = get_term($current_term->term_id); do_action( 'wpml_switch_language', null ); if (isset($orignal_term->slug) && $orignal_term->slug !== $current_term->slug ) { array_push($templates, $orignal_term->taxonomy . '-' . $orignal_term->slug); } } return $templates; } add_filter('taxonomy_template_hierarchy', 'wpmlsupp_10867'); 4. Save the changes. It should fix the issue. This issue has been escalated to our developers. They will check it and release a fix in future versions of WPML. I'll update you once the version with the fix is released. Thank you for your patience. |
July 5, 2023 at 1:26 pm #13951019 | |
alexanderC-32 |
Hi Itamar, Thanks for the update. I've followed the steps to add the function but unfortunately I'm still seeing the same, incorrect template. I've cleared all caches and still no luck. Were you able to get it working on your end? |
July 5, 2023 at 6:39 pm #13953441 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, I wanted to check your site to see if I can make it work with the provided function, but I got a message that the password is incorrect. If you are stuck, please use the first workaround I provided. See it in my previous reply here. https://wpml.org/forums/topic/translated-taxonomy-not-showing-correct-template/#post-13928681 I checked this method, and it also works. Please share the correct access details if you want me to check things on your site. I'm enabling a private message for the following reply. Regards, |
July 5, 2023 at 6:58 pm | |
July 5, 2023 at 7:09 pm #13953521 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, and thanks for the access details. I checked your site now, and I can see that the problem with the English template is solved now. The template is not broken, and the slug is in English. Please see the attached screenshot. hidden link Can you confirm that it is OK now? |
July 5, 2023 at 7:44 pm #13953723 | |
alexanderC-32 |
Hi Itamar, No, it was never the English template that had the problem; it was always the French template. I was playing around a bit since you provided the function, and I'm noticing that it appears that the problem could be due to the fact that the French version's template name isn't translating like the other species' templates. For example, when I'm on the French side, and I go to edit the Species: Baies template, you'll see that the slug isn't translated. But if you go to Species: Fleurs, you'll see that the slug is translated. Do you think this could be part of the issue? Right now, after I've messed around with the templates a bit, the French side of the berries term is showing what looks to be the index template, and not the baies template. |
July 6, 2023 at 1:36 pm #13960485 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, I'm sorry it was my mistake. Indeed it was the French template. You wrote: "Right now, after I've messed around with the templates a bit, the French side of the berries term is showing what looks to be the index template, and not the baies template." The problem is that WPML does not recognize the translated template and therefore the wrong template shows. I checked your site and the functions.php file of your theme - Western Arctic Ethnobotany Garden. I don't see our function there. Please see the attached screenshot. Did you try to add it there? I wanted to add it myself but was concerned that if something goes wrong, I'll be locked out of your site. So if you want time to try this, please share with FTP access. For this, I'm enabling a private message for the next reply. |