Join our new community forum for support & discussion

Join Now

Home Support Themes ExpertHive Adding location to sidebar filter

Adding location to sidebar filter

  • Author
    Posts
  • namtrandpm

    Is there any way to add the geolocation filter to the sidebar?

    namtrandpm

    Just checking in to see if anyone has run into this issue and found a solution.

    yevhen developer

    If you mean moving the Location field from the search bar to the search filters form please try this code snippet:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['location'] ) ) {
    			$attributes['location'] = array_merge($attributes['location'], ['searchable' => false, 'filterable' => true]);
    			$attributes['latitude'] = array_merge($attributes['latitude'], ['searchable' => false, 'filterable' => true]);
    			$attributes['longitude'] = array_merge($attributes['longitude'], ['searchable' => false, 'filterable' => true]);
    		}
    
    		return $attributes;
    	},
    	1000
    );
    namtrandpm

    This works perfectly!

Viewing 4 posts - 1 through 4 (of 4 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.