Skip Navigation

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: 

This topic contains 24 replies, has 2 voices.

Last updated by Itamar 1 year, 6 months ago.

Assisted by: Itamar.

Author Posts
July 6, 2023 at 1:47 pm
July 6, 2023 at 4:44 pm #13962233

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi, and thanks for the FTP details.

I wanted to check the issue, but now it seems OK. And, now, I'm checking the French page. The slug is translated, and the layout is not broken and is the same as in English. Please see the attached screenshot.

Have you found a way to fix it?

2023-07-06_19-41-19.jpg
July 6, 2023 at 6:38 pm #13962853

alexanderC-32

Hi Itamar,

I wouldn't say it's fixed necessarily, I just ended up adding a custom block that looped through the term and displayed those posts, depending on which term page you were on.

There still is an issue where WPML isn't able to properly translate the FSE template I created for the specific taxonomy term, berry. The shrubs and flower term templates are working in French, but not the berry template. Very strange. It would be good to resolve this.

Is there any other debugging you can do?

July 9, 2023 at 10:44 am #13972623

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I compared the English and French pages, which looked the same. This is why I assumed that the issue was fixed. I didn't know that you changed the template or how.

Let me please summarize this case. You presented a particular problem. We debugged it and recognized the source of the problem from WPML's side. We provided two workarounds and escalated the issue to our developers. You said the first workaround worked for you but is less preferable. You said that the second workaround is not working for you. We have two options until our developers will address this issue and fix it in future versions of WPML.

A. You apply the first (less preferable) workaround.

B. You will recreate the issue on your site so we can check why the function we provided is not working on your site. I'll then be able to present it to our second-tier supporter.

Please let me know how you want to continue.

July 11, 2023 at 3:01 pm #14016363

alexanderC-32

Hi Itamar,

Thanks for the summary. I will go with B, and let you know once I've re-created the issue so that you may check why the function was not working.

July 11, 2023 at 7:43 pm #14017815

alexanderC-32

Hi Itamar,

I've now re-created the issue that I was experiencing before. You'll see I've created a new template for the berry species, and have added a line directly before the list of berries that says 'This is the berry template' on the English version, but it's not being rendered on the French version, even though the French version of the template exists in the template area. What I think it's doing is inheriting the Species taxonomy template, and not the more specific berry term template, for French.

July 12, 2023 at 6:08 am #14019027

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Thanks for recreating the issue. I can now see that the text you added is not on the translated French page. I also tried things myself. I added the function directly in the functions.php and did not include it in a separate file as you did it. (It is just to check that there is no problem with the inclusion.) I then retranslated the page, but it didn't solve the problem. I've shared this information with our second-tier supporter. When I have his reply on this, I'll share it with you here.

July 12, 2023 at 11:58 am #14023759

alexanderC-32

Hi Itamar,

Thanks for looking into this.

July 17, 2023 at 2:20 pm #14050389

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Our second-tier supporter has fixed the issue on your site. Now the correct template is shown in French here.

hidden link

Apparently, there was a mistake in the code we shared with you. The second-tier supporter corrected the function and, as I mentioned, already applied it on your site. For the record, the corrected function is this.

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_unshift($templates, 'taxonomy-' . $orignal_term->taxonomy . '-' . $orignal_term->slug);    
      }
  }

  return $templates;
}
add_filter('taxonomy_template_hierarchy', 'wpmlsupp_10867');

However, the second-tier supporter is unsure how you are adding the term template without adding an HTML file in the theme.

Could you please tell us what tools/methods you use to add the term template?

We ask this because, from the backend, we can't add term-specific templates.

Thanks,
Itamar.

2023-07-17_17-08-07.jpg
July 18, 2023 at 11:51 am #14058985

alexanderC-32

Hi Itamar,

Thanks for the update. I see that things are working now.

I add the term specific template from the FSE area under Appearance > Editor > Templates, then add a new template using the + sign icon, next to Templates heading, and choose Species > Baies (or whatever term is hasn't been assigned a template). Right now, all of the species terms have been assigned a template, so they're not going to show up while following the instructions above.

If you delete a term template for a specific term, it will again show up in the list when following the instructions above. When I was trying to troubleshoot, I decided to simply create a species template that would loop through whatever term I was on, instead of using term-specific templates, as all term templates are going to be using the same components. But, there may be cases in the future where I'd want to have a term-specific template, so it was good to troubleshoot this issue, as it was clearly a bug.

July 19, 2023 at 5:19 am #14062509

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Thank you so much for your answer.

I passed it to our second-tier supporter. The issue is still being escalated to our developers. I'll update you here once I have news about this issue.

August 9, 2023 at 5:33 pm #14177749

alexanderC-32

Hi Itamar,

It’s been a few weeks now, any update from the second tier support?

August 10, 2023 at 11:55 am #14182039

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Right now, I have no news about this. Let me please remind you that this issue has been escalated to our developers. It has the following description of the problem.

Full Site Editing -> Specific Category template depends on the "post_name" to match the slug of the term.

It is up to our developers to decide when to handle this. We provided you with a workaround, which you confirmed works. I'll update you here once the version with the fix is released.

Regards,
Itamar.