• aloppnow

    (@aloppnow)


    I’m trying to restrict the Search results by State and I’m using the wpsl_geocode_components Filter code from the Documentation (just replacing Illinois with Maine).

    
    add_filter( 'wpsl_geocode_components', 'custom_geocode_components' );
    
    function custom_geocode_components( $geocode_components ) {
                
        $geocode_components['administrativeArea'] = 'Maine'; 
        return $geocode_components;
    }
    

    When I use this filter the initial lookup after page load works (defaulting to the set location in the settings or user location if allowed).

    Each additional search (City name or Zip) fails to find any results, when I remove the filter the search works fine just looks out of state for city names (zip codes work).

    I checked Googles API documentation about the administrativeArea and it appears to be set correctly. The HTTP response from google gives me the boundaries for the state and the administrative_area_level_1 etc information.

    It just defaults to an odd place in the middle of the state.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    You are not the only one who has a problem with this, but I haven’t had time to really look into it myself, and see why it breaks. I will try and do this really soon, and get back to you about this.

    Thread Starter aloppnow

    (@aloppnow)

    great thank you, we are an agency building custom themes and plugins so let us know what help you need.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpsl_geocode_components Filter breaks search’ is closed to new replies.