Tell us what you are trying to do?
hidden link
I want to set the default value of country be "USA" in shortcode, I'm using elementor. And current shortcode I'm using is:
[wpv-form-view name="search-home-2" target_id="1763"]
Hello,
The simplest way is passing URL parameter, for example:
hidden link
And you can setup custom JS codes to setup the default value, for example:
jQuery( document ).on( 'ready', function( event, data ) {
jQuery('select[name="wpv-country"]').val('usa');
});
Thank you Luo!
I added the custom JS to the page, but when page is loaded, it does preset the filter to be USA, but another filter on the right - "States & City" still shows cities in other country. Is there anyway to make it sync with the "Country" filter?
Thanks!
I just installed a redirection plugin to pass the URL parameter when home page is loaded, but I feel it's not a good way to solve this problem. Would like to hear your suggestion. Thanks
It needs other custom codes, for example:
1) Create a custom shortcode to setup the default URL parameter value, add below codes into your theme file "functions.php":
add_shortcode('set_default_url_param', function($atts){
$atts = shortcode_atts( array(
'param' => 'wpv-country',
'value' => 'usa'
), $atts);
if(!isset($_GET[$atts['param']])){
$_GET[$atts['param']] = $atts['value'];
}
return;
});
2) Display above shortcode just above the view's shortcode, for example:
[set_default_url_param]
[wpv-form-view name="search-home-2" target_id="1763"]