<?php
/** instead of indexing the value of a field, index a value and label to indicate the custom field exists for that post **/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_facet' == $params['facet_name'] ) { // change my_facet to the name of your facet
if (!empty( $params['facet_display_value'] ) ) {
$params['facet_value'] = 'true'; // this will be the value in the filter url
$params['facet_display_value'] = 'Has Value'; // this is the label you want the facet to show
} else {
return false; // don't index is value is blank
}
}
return $params;
}, 10, 2 );