Passer la navigation

[Résolu] Filtering categories in search options

This support ticket is created Il y a 1 year. There's a good chance that you are reading advice that it now obsolete.

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 -

Fuseau horaire du supporter : Asia/Kolkata (GMT+05:30)

Ce sujet contient 18 réponses, a 1 voix.

Dernière mise à jour par - Il y a 1 year.

Assisté par: Minesh.

Author
Publications
#2833164

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: 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
Supporter

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

I've also disable the cache for the view, please check the following screenshot:
- lien caché

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 🙂