• I have 2 locator pages, one for USA and one for Canada. I want the specific pages to only show the locations for that country.
    I am using the script found in documentation to restrict search results to country. It works to not allow user to type in an address from another country, but if there is a nearby search result from across the border, it still shows that store location from the other country.
    Is there a way to keep ONLY the stores in that specific country in the results?

    Here is the code I’m using:

    add_filter( ‘wpsl_geocode_components’, ‘custom_geocode_components’ );

    function custom_geocode_components( $geocode_components ) {

    if ( is_page( ‘dealer-locator-canada’ ) ) {
    $geocode_components[‘country’] = ‘ca’;
    } else if ( is_page( ‘find-dealer’) ) {
    $geocode_components[‘country’] = ‘us’;
    }

    return $geocode_components;
    }

    As an example to see what is happening, try searching Bellingham, WA. You get one search result in the US and another in Canada. I only want US stores on this page.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi there!

    Unfortunately right now the plugin does not support an easy way to restrict results by country. The only workaround by now is to categorize the stores by country and restrict the search to the desired country or countries selecting the corresponding categories. But this is far from ideal.

    Proper restriction by country is planned for release in the next major version 3.0, which is in an advanced state of development, although there is still not a precise release date, so stay tuned!

    Regards,

Viewing 1 replies (of 1 total)
  • The topic ‘Restricting search results by country’ is closed to new replies.