Created
November 24, 2024 20:00
-
-
Save hivepress/aa052e01df04691a45e5ffef4589a040 to your computer and use it in GitHub Desktop.
Add region filter to the Listings block settings #hivepress #geolocation
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_filter( | |
'hivepress/v1/models/listing/attributes', | |
function( $attributes ) { | |
$field_args = [ | |
'label' => 'Region', | |
'type' => 'select', | |
'options' => 'terms', | |
'option_args' => [ 'taxonomy' => 'hp_listing_region' ], | |
'_order' => 199, | |
]; | |
$attributes['region'] = [ | |
'protected' => true, | |
'filterable' => true, | |
'edit_field' => $field_args, | |
'search_field' => $field_args, | |
]; | |
return $attributes; | |
}, | |
1000 | |
); | |
add_filter( | |
'hivepress/v1/forms/listing_filter', | |
function( $form ) { | |
$form['fields']['region']['display_type'] = 'hidden'; | |
return $form; | |
}, | |
1000 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment