Hi,
it’s possible to some extent, i understand you have the search by category dropdown configured using Custom Fields, if so then the below code will hide the empty categories in the search, just replace “custom_field_100” with the actual name of the dropdown with the categories list
function adverts_taxonomies_no_empty( $taxonomy = 'advert_category' ) {
$args = array(
'taxonomy' => $taxonomy,
'hierarchical' => true,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true,
'depth' => 0,
'selected' => 0,
'show_count' => 0,
);
include_once ADVERTS_PATH . '/includes/class-walker-category-options.php';
$walker = new Adverts_Walker_Category_Options;
$params = array(
get_terms( $taxonomy, $args ),
0,
$args
);
return call_user_func_array(array( &$walker, 'walk' ), $params );
}
add_filter( "adverts_form_load", function( $form ) {
if( $form["name"] != "search" ) {
return $form;
}
foreach( $form["field"] as $k => $field ) {
if( $field["name"] == "custom_field_100" ) {
$form["field"][$k]["options_callback"] = "adverts_taxonomies_no_empty";
}
}
return $form;
} );
With the location field in Maps and Location it’s not really possible to hide the empty categories right now since the suggestions cannot distinguish between search and add form, so the empty locations would be also hidden in the [adverts_add] which would make it impossible to add new Ads to empty categories, but a future update should have some solution which will allow modifying the returned options.