Created
June 2, 2026 18:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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