Skip to content

Instantly share code, notes, and snippets.

@hivepress
Created June 2, 2026 18:54
Show Gist options
  • Select an option

  • Save hivepress/9ae853f3b955f4c2dd94f08f95e587cc to your computer and use it in GitHub Desktop.

Select an option

Save hivepress/9ae853f3b955f4c2dd94f08f95e587cc to your computer and use it in GitHub Desktop.
Change the search logic to "equals or more" for specific listing attributes #hivepress #listings
<?php
add_action(
'hivepress/v1/models/listing/search',
function( $query ) {
$fields = [ 'bedrooms', 'bathrooms', 'custom_attribute_name' ];
$meta_query = (array) $query->get( 'meta_query' );
foreach ( $fields as $field ) {
if ( isset( $meta_query[ $field ] ) ) {
$meta_query[ $field ]['compare'] = '>=';
}
}
$query->set( 'meta_query', $meta_query );
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment