Hi there,
Well, there is not a built-in solution for that but we can do the trick using a bit of javascript. Place this code snippet at the end of your active theme’s functions.php file:
add_action( 'wp_footer', function () { ?>
<script type='text/javascript'>
// pure jquery snippet for loading the search from GET parameter in the search field and clicking the button
jQuery( window ).load(function() {
let searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('location')) {
let location = searchParams.get('location');
jQuery('#wpsl-search-input').val(location);
} else {
console.log('location not received');
}
});
</script>
<?php } );
Then the site is ready to receive the “location” parameter in the url, so if for instance your wp store locator is showing at https://mydomain.com/stores, and you want to create predefined buttoms with the cities “Omaha” and “Phoenix”, you can insert buttons that link to these urls, and they will work:
<a href="https://mydomain.com/stores?location=Omaha">Omaha</a>
<a href="https://mydomain.com/stores?location=Phoenix">Phoenix</a>
I hope that helps.
Regards ??
-
This reply was modified 2 years, 6 months ago by farroyo.
-
This reply was modified 2 years, 6 months ago by farroyo.