<?php
function fwp_max_capacity( $return, $params ) {
$facet_name = $params['facet']['name'];
if ( 'max_capacity' == $facet_name ) {
$values = $params['selected_values'];
$max_capacity = ( '' == $values[0] ) ? false : $values[0];
global $wpdb;
if ( false !== $max_capacity ) {
$where .= " AND (facet_value + 0) >= '$max_capacity'";
}
$sql = "
SELECT DISTINCT post_id FROM {$wpdb->prefix}facetwp_index
WHERE facet_name = '$facet_name' $where";
return $wpdb->get_col( $sql );
}
return $return;
}
add_filter( 'facetwp_facet_filter_posts', 'fwp_max_capacity', 10, 2 );