Hi there!
The way that comes to my mind for doing this is with a little jquery snippet.
What we basically do is, we check if we received a GET parameter called “location” and, if so, we manually trigger a search as if we were introducing the value in the search box and clicking “Search”. It is rudimentary but it works.
/* pure jquery snippet for loading the search from GET parameter in the search field and clicking the button */
add_action( 'wp_footer', function () { ?>
<script type='text/javascript'>
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);
jQuery('#wpsl-search-btn').trigger('click');
} else {
console.log('location not received');
}
});
</script>
<?php }, 100 );
I hope that helps.
Regards,