Hi Maurino
We have a WP / PHP hook which you can use to modify each individual option in your field – you could then loop through all your options, count the total results, and add that to the first option (All Items) – this is the filter: https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
I’ve actually gone ahead and managed to create a code snippet for you that does this:
function add_count_to_first_option( $input_object, $sfid ) {
// if the field doesn't have input options, then leave it alone
if ( ! isset( $input_object['options'] ) ) {
return $input_object;
}
$total_count = 0;
// loop through each option and add up the total count
foreach ( $input_object['options'] as $option ) {
if ( isset( $option->count ) ) {
$total_count += absint( $option->count );
}
}
// now check to make sure there was a first option (with value of "")
// and update its count
if ( isset( $input_object['options'][0] ) ) {
if ( '' === $input_object['options'][0]->value ) {
$input_object['options'][0]->label .= ' (' . $total_count . ')';
}
}
return $input_object;
}
add_filter('sf_input_object_pre', 'add_count_to_first_option', 10, 2);
Add this to your themes functions.php, and that will add a count to all first options in your fields.
Thanks