Skip Navigation

[Resolved] Toolset view not working in translated pages with wpml

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 6 replies, has 2 voices.

Last updated by charitosA 1 month, 2 weeks ago.

Assisted by: Christopher Amirian.

Author
Posts
#2751365
isis1.png

Tell us what you are trying to do?
- I am trying to fully translate the website and I cannot make the custom view to work on the translated pages.

Is there any documentation that you are following?
- no
Is there a similar example that we can see?
- no
What is the link to your site?

- hidden link on the Greek pages about the clinic and the team where we display the team members.

#2751405

Christopher Amirian
Supporter

Languages: English (English )

Hi You need to translate the view to be able to see it in the second language.

Please follow the steps below to do that:

https://toolset.com/course-chapter/translating-directory-and-classifieds-sites/?_gl=1*1yy6zby*_gcl_au*MTg3OTc0MjAyOC4xNzIwMjUyNzA2

#2751449

Hi Christopher,

I tied this already. It won't work. I have some custom codes in functions.php for the filters and I am not sure if I have to add the translated categories too in the array.

This is one of the custom filters:
add_filter( 'wpv_filter_query', 'filter_include_cat_fn_159', 1000 , 3 );

function filter_include_cat_fn_159( $query_args, $view_settings ) {
if ( isset( $view_settings['view_id'] ) && $view_settings['view_id'] == 159 ) {
if ( empty( $query_args['tax_query'] ) ) {
$query_args['tax_query'][0]['taxonomy'] = 'bottom-position';
$query_args['tax_query'][0]['field'] = 'slug';
$query_args['tax_query'][0]['terms'] = array( 'expert-doctors', 'midwives', 'nurses', 'care-taker', 'admin', 'accounting', 'services' );
$query_args['tax_query'][0]['operator'] = 'IN';
$query_args['tax_query'][0]['include_children'] = '';
$query_args['tax_query']['relation'] = 'AND';
}
}
return $query_args;
}

#2754492

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Yes first thing first, you need to translate everything including the categories.

Then, you need to check if the filters show if you do not even use the custom code. As from the screenshot you shared on the first question, the filters do not show at all.

Test by removing the additional code and see if a normal workflow shows the translated filters.

Now if the filters show correctly then add the code and from what I see in the code you only need to check the translated version of the taxonomies.

You can use the hook below to know which language you are in and add the proper text for that language on your code:

https://wpml.org/faq/how-to-get-current-language-with-wpml/

Finally, you can translate the text that you used on the view following the steps below:

https://toolset.com/forums/topic/how-to-translate-filters-and-static-and-dynamic-texts-of-a-view/#post-2613163

Thanks.

#2769381

Hello Christopher,

I have followed the instructions.
I checked all the string translations etc. and still no result.
I found this:
- in the original en language displays: <label for="top-position-fertility" class="form-check-label">Fertility</label>
- in the translated gr language doesn't display it: <label for="top-position-%ce%b3%ce%bf%ce%bd%ce%b9%ce%bc%cf%8c%cf%84%ce%b7%cf%84%ce%b1" class="form-check-label">Γονιμότητα</label>

the other ''maternity'' position is not loading on gr version.

#2770032

Christopher Amirian
Supporter

Languages: English (English )

Hi,

I think the translation is done correctly and it is now showing on HTML.

The problem is that by translating the label the generated label is also in Greek and you have a CSS code that hides all the filters except the current ones and you used the label name for that. In English, it works:

form[name="wpv-filter-155"] .form-group label[for="top-position-fertility"], form[name="wpv-filter-155"] .form-group label[for="top-position-maternity"] {
    display: block;
}

But in Greek the CSS above does not apply as the label of the field is not "top-position-fertility" or "top-position-maternity".

It is "top-position-%ce%b3%ce%bf%ce%bd%ce%b9%ce%bc%cf%8c%cf%84%ce%b7%cf%84%ce%b1"

You need to add proper CSS code for the Greek version.

I managed to show one section:

form[name="wpv-filter-155"] .form-group label[for="top-position-%ce%b3%ce%bf%ce%bd%ce%b9%ce%bc%cf%8c%cf%84%ce%b7%cf%84%ce%b1"],
form[name="wpv-filter-155"] .form-group label[for="top-position-%ce%bc%ce%b7%cf%84%cf%81%cf%8c%cf%84%ce%b7%cf%84%ce%b1"] {
    display: block !important;
}

But I am not sure about the other one.

By the you can use the site below to encode or decode the "%ce%b3%ce%bf%ce%bd%ce%b9%ce%bc%cf%8c%cf%84%ce%b7%cf%84%ce%b1" to see what it is actually in Greek.

hidden link

Thanks.

#2774517

Thank you Christopher for the help. This solved the display problem.