Hello,
On the website, I created an archive page ( hidden link ) which there is on the left a menu. The first part of the menu has the list of regions "piemonte, lombardia,...". It's possible to remove automatically some of these items if they are empty? For example, if you select "lombardia" and click on "Cerca farmacie" the next page show the message " Non ci sono farmacie..."
I don't want to show items on the menu the doesn't have any results
thanks

Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details and let me see if I'm able to share any workaround for this issue.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.
I tried to follow the link you shared but I do not get access to admin.
Could you please share admin access details.
I have set the next reply to private which means only you and I have access to it.
Could you please check now: hidden link
To filter the terms displayed with the taxonomy filter with the view, Toolset offers the hook "wpv_filter_taxonomy_frontend_search_available_terms" using which we can fitter the taxonomy filter terms.
I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link
add_filter( 'wpv_filter_taxonomy_frontend_search_available_terms', 'func_show_only_terms_having_posts_in_filter', 10, 3 );
function func_show_only_terms_having_posts_in_filter( $terms, $taxonomy, $view_id ) {
$terms_to_return = array();
if($view_id == 235 && $taxonomy =='regione'){
foreach ( $terms as $term ) {
if ( $term->count !== 0 ) {
$terms_to_return[] = $term;
}
}
}
return $terms_to_return;
}
More info:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_available_terms
Hello,
there is still an error... fatturato is empty and it must be visible
Could you please check now: hidden link
I've adjusted the code added to "Custom Code" section as given under:
add_filter( 'wpv_filter_taxonomy_frontend_search_available_terms', 'func_show_only_terms_having_posts_in_filter', 10, 3 );
function func_show_only_terms_having_posts_in_filter( $terms, $taxonomy, $view_id ) {
$terms_to_return = array();
if($view_id == 235 && $taxonomy =='regione'){
foreach ( $terms as $term ) {
if ( $term->count !== 0 ) {
$terms_to_return[] = $term;
}
}
$terms = $terms_to_return;
}
return $terms;
}
I can see it works as expected.
It works perfectly thanks so much but, I don't understand what change you did to the code because I can't see the difference...Can you explain, please?
This line of code is added:
$terms = $terms_to_return;
And the return statement is changed from:
To:
Yes, I checked well before you reply and I saw it... thanks so much, I learned a new thing about your plugin 🙂
My issue is resolved now. Thank you!