Skip Navigation

[Resolved] Split: Txonomy filters not displaying on all pages correctly – issue with term order

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 0 replies, has 0 voices.

Last updated by charitosA 5 days, 9 hours ago.

Assisted by: Minesh.

Author
Posts
#2791270

Hello Minesh,

Thank you for adding this shortcode. Now the descriptions are visible in both languages.
The issue with the order on both languages and preselected 'expert-doctors' by default in Greek pages remains.
This is the updated function to the new view and how the categories order should be:

// filters for all team members by priority category
add_filter( 'wpv_filter_query', 'filter_include_cat_fn_49247', 1000 , 3 );

function filter_include_cat_fn_49247( $query_args, $view_settings ) {
if ( isset( $view_settings['view_id'] ) && $view_settings['view_id'] == 49247 ) {
if ( empty( $query_args['tax_query'] ) ) {
$query_args['tax_query'][0]['taxonomy'] = 'top-position';
$query_args['tax_query'][0]['field'] = 'slug';
$query_args['tax_query'][0]['terms'] = array( 'expert-doctors', 'embryologists', 'midwives', 'nurses', 'care-taker', 'treatment', 'administration', '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;
}

However, at the moment, it is displaying wrong order in English: Expert Doctors, Embryologists, Accounting, Administration, Midwives, Nurses, Services, Care Taker, Treatment.

#2791473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and admin access details.

Also - what is the exact order of the terms you wish to display?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2791636

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The code you are using is wrong. You can use "wpv_filter_query" hook to filter the view results.

To filter or order the taxonomy filter terms you can use the hook "wpv_filter_taxonomy_frontend_search_get_terms_args":
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_available_terms

For exmaple - I've added the following filter code to "Custom Code" section offered by Toolset:
=> hidden link

add_filter('wpv_filter_taxonomy_frontend_search_get_terms_args','func_filter_tax_terms_custom_order',10,3);
function func_filter_tax_terms_custom_order( $args, $tax, $view_id ){
     global $WP_Views;
    if ( $view_id == 49247  && $tax == 'top-position' ){
        $args['orderby']='slug__in';
        $args['slug'] = array( 'expert-doctors', 'embryologists', 'midwives', 'nurses', 'care-taker', 'treatment', 'administration', 'accounting', 'services' );
          
    }
   
    return $args;
}

Can you please confirm the order of taxonomy terms is correct now:
- hidden link

#2792416

Hi Minesh,

I apologize for the late reply. The English version is in the correct order now. However, the Greek one is not.

#2792436

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now:hidden link

I've adjusted code to "Custom Code" section as given under:
=> hidden link

add_filter('wpv_filter_taxonomy_frontend_search_get_terms_args','func_filter_tax_terms_custom_order',10,3);
function func_filter_tax_terms_custom_order( $args, $tax, $view_id ){
     global $WP_Views;
    if ( $view_id == 49247  && $tax == 'top-position' ){
        $args['orderby']='slug__in';
        $current_language = apply_filters( 'wpml_current_language', null );
        if($current_language=='el'){
          	$args['slug'] = array( 'γιατροί', 'εμβρυολόγοι', 'μαίες', 'νοσοκόμες', 'φροντιστές-θαλάμου', 'θεραπεία', 'διοίκηση', 'λογιστήριο', 'υπηρεσίες' );
        }else{
          	$args['slug'] = array( 'expert-doctors', 'embryologists', 'midwives', 'nurses', 'care-taker', 'treatment', 'administration', 'accounting', 'services' );
        }
      
        
          
    }
   
    return $args;
}

Can you pleaes confirm it works as expected.

#2792885

Hi Minesh,
Thank you so much for the adjustment. It has the correct order. The only unresolved issue from this taxonomy filter is the doctors to be pre-selected as they are in the English version.
We are expecting on page load the result in Greek to be like this:
hidden link

#2793119

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

I've adjusted the code added to "Custom JS" box of your view as given under:
=> hidden link

jQuery(document).ready(function($){
  var params = new window.URLSearchParams(window.location.search);
  var myurl = new URL(window.location.href);
  
   if($('html').attr('lang')=='el' && !myurl.searchParams.has('wpv-top-position')){
    $('input:radio[name=wpv-top-position][value=γιατροί]').click();
  } else {
 
      // console.log(myurl.searchParams.has('wpv-team-member-type'));
      if(!myurl.searchParams.has('wpv-top-position')){
        $('#top-position-expert-doctors').attr('checked', true).trigger('change');
      }
  }
   
});

I hope this will fix your issue.

#2793321

Hi Minesh,
This update resolved my display issues.
Thank you so much for your assistance.