Restricting search results by country
-
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]
- The topic ‘Restricting search results by country’ is closed to new replies.