Skip to content

Instantly share code, notes, and snippets.

@hivepress
Created November 24, 2024 20:00
Show Gist options
  • Save hivepress/aa052e01df04691a45e5ffef4589a040 to your computer and use it in GitHub Desktop.
Save hivepress/aa052e01df04691a45e5ffef4589a040 to your computer and use it in GitHub Desktop.
Add region filter to the Listings block settings #hivepress #geolocation
<?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