Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client uses the legacy Views editor to create a View to display taxonomy terms.

The texts from the View are translated via String Translation, but on the translated page the View query returns no results, unlike in the default language where all of the taxonomy terms are shown.

Solution:
The problem was that the output of the View is ordered by a taxonomy custom field, and in WPML settings that term field is set as Do not translate. That means that in the secondary language the terms have no values for that custom term field.

It is a quirk of WordPress that when ordering by some thing, and potential results that have no value for that thing will be excluded from the results.

The solution is to copy or translate the custom term fields.

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 14 replies, has 2 voices.

Last updated by matthewL-3 1 year, 3 months ago.

Assisted by: Nigel.

Author Posts
February 20, 2024 at 12:45 pm #15322717

matthewL-3

Hi

On the homepage - hidden link you can see the country flags

But on a translated version you can't hidden link

This is a Toolset view, I am guessing it needs translating but how do I do that?

The homepage is showing as fully translated and Toolset views don't have the option to translate in Translation Management?

This is a Toolset view using the old editor not the block editor as the block editor does not support taxonomy yet.

February 21, 2024 at 8:54 am #15326060

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Hi there

As you may be aware, the Toolset View block is integrated with WPML so that when translating a page containing such a View all of it's texts are offered for translation.

With the legacy View editor you translate texts by wrapping them in the wpml-string shortcode (see https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpml-string), and then locating them for translation in String Translation.

But in your case the problem looks different.

When switching to the Spanish page, the View doesn't find any results. That means that the content being queried (maybe you have a "flag" custom post type) has not been translated, and so there are no results to show on the Spanish page.

So you will first need to translate the "flag" content, and then worry about translating any strings output by the View, by using the wpml-string shortcode.

February 21, 2024 at 10:23 am #15326864

matthewL-3

Ah I see it’s not that though because the flags are just the default WordPress categories and they have been translated.

Any other thoughts what it could be?

February 21, 2024 at 11:24 am #15327377

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Hmm. I set up a local test site and I'm seeing something similar.

I need to dig into this a little further to see if I can spot what the problem is.

Please bear with me, I'll get back to you when I have some news.

February 21, 2024 at 11:46 am #15327557

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

It may just be a caching issue.

On the page where you have inserted the shortcode for the Toolset View (including on the translated page), add the cached="off" attribute to the wpv-view shortcode.

If your categories are translated double-check that the translated categories are assigned to some posts so that the term count is not zero.

February 21, 2024 at 1:46 pm #15328306

matthewL-3

No same issue still and the categories are translated and definitely have posts.

February 21, 2024 at 2:14 pm #15328597

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Could I take a look at your site?

I'll want to temporarily add one or two plugins to aid with debugging, if that's okay.

Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

February 22, 2024 at 8:14 am #15331540

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Thanks for that, but I can't log in, it looks like you have an additional security layer, and maybe a misconfigured reCaptcha?

Screenshot 2024-02-22 at 08.12.42.png
February 22, 2024 at 11:36 am #15333203

matthewL-3

Sorry about that resolved that for you!

February 22, 2024 at 1:49 pm #15333854

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

OK, I spotted a couple of things, the first is simply that you missed a quote when adding the cached="off" attribute, which I fixed on this site copy.

That didn't resolve the problem, but I see the cause of it is that you are ordering your View by a term meta field (clean country name), and that that field is set to not translate.

That means that the translated categories have no value in the database for that field, and it is a quirk of WordPress that if you order a query (in this case a taxonomy query) by something, potential results that have no value for that thing are omitted.

Screenshot 2024-02-22 at 13.45.47.png
Screenshot 2024-02-22 at 11.57.29.png
February 22, 2024 at 10:27 pm #15335745

matthewL-3

ah of course I totally forgot I changed that! thank you! I have moved this to be translated now but I can't for the life of me figure out how to translate it?

The page does not flag it still as needing translation, can't find it in translation management or in strings. (made this change on the live site to try and do it).

Also I fixed the cached tag on the live site.

February 23, 2024 at 8:59 am #15336608

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

If you have marked the taxonomy custom term meta for translation then when you edit term translations via WPML > Taxonomy translation you will see the term meta offered for translation (screenshot is from my own test site).

You can re-send content that has the categories assigned for translation to have the term meta translated, and there is a simple trick to translate them all in one go as described here: https://wpml.org/faq/how-to-translate-all-taxonomy-terms-at-once/

Screenshot 2024-02-23 at 08.50.35.png
February 23, 2024 at 4:02 pm #15338661

matthewL-3

We are closer but the flag images are not showing up now.

See: hidden link

Any ideas why this might be?

February 26, 2024 at 8:02 am #15342548

Nigel
WPML Supporter since 02/2016

Timezone: Europe/Madrid (GMT+02:00)

Did you also change the translation settings for the wpcf-country-flag custom term meta in WPML > Settings?

In your staging site it is still set as do not translate, and I expect you will want to set it as Copy for an image url.

February 26, 2024 at 12:08 pm #15344004

matthewL-3

Yes but only recently is there a way to trigger the system knowing about this change?

I changed resaving the page but that made no difference.