Saltar navegación

[Resuelto] Filtering categories in search options

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 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 18 replies, tiene 1 mensaje.

Última actualización por - 1 year ago.

Asistido por: Minesh.

Author
Mensajes
#2833164

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

I checked and I would like to know why you added the same taxonomy filter for "category" two times. One time as drop-down select and secondly as checkboxes?

#2833166

the first category dropdown will be only a search option for the YEARS category and shall display only some parent categories (i.e. years). The second filter (checkboxes) shall be filter as my ticket request.
Is it possible to display both filters?

#2833202

if it is not possible to have both category filters, please keep only the checkbox one.

Kindly let me know, thanks,

Franco

#2833218

Minesh
Colaborador

I've removed the drop-down select filter from your view from backend and saved the page:
=> enlace oculto

I've also disable the cache for the view, please check the following screenshot:
- enlace oculto

The custom code is adjusted as given under:

add_filter( 'wpv_filter_taxonomy_frontend_search_get_terms_args', 'func_allow_only_child_terms_in_custom_search_filter', 10, 3 );
function func_allow_only_child_terms_in_custom_search_filter( $args, $taxonomy, $view_id ) {
  
 
    // target parent term ID
    $parent_term_id = 3;
      
   // target taxonomy slug
    $target_taxonomy_slug = 'category';
     
   // target view's ID
    $target_view_ids = array( 5264 );
  
    // check if specific view
    if ( in_array( $view_id, $target_view_ids ) and $taxonomy==$target_taxonomy_slug ){
  
      	
      // get child terms of the target parent term
     //   $termchildren = get_term_children( $parent_term_id, $target_taxonomy_slug );
      
        // include only those child terms in search filter
        $args['slug'] = array('articoli-e-pubblicazioni', 'eventi', 'nella-stampa');
        //$args['include'] = array(40,41,42);
  
    }
   
    return $args;
}

Can you please confirm it works as expected.

#2833236

thanks it works 🙂