I used this snippet from GitHub to set the location field for specific categories only, but this also removes it from the search bar by default because no category is selected (like on the homepage).
Is there a way to customize the snippet so it only applies to the Add/Update Listing pages and the admin area? Or do you have a snippet to add it back to the search bar?
Thank you!
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['location'] ) ) {
$categories = [ 1, 2, 3 ];
$attributes['location']['categories'] = $categories;
$attributes['latitude']['categories'] = $categories;
$attributes['longitude']['categories'] = $categories;
}
return $attributes;
},
1000
);