Hi,
your offer is better than WPML’s. This saves the category value and the search word in the search filter. How do I do that?
I’m wondering if we can redirect a user to a search page in the active country.
Add following PHP snippet to do that.
/**
* Redirect to default country.
*/
function gd_snippet_20190902_wpml_url_parameters_gets_passed( $gets_passed, $code, $url ) {
global $geodirectory;
if ( ! empty( $_REQUEST['geodir_search'] ) && ! empty( $gets_passed['geodir_search'] ) ) {
$set_country = false;
if ( ! empty( $gets_passed['spost_category'] ) ) {
$set_country = true;
unset( $gets_passed['spost_category'] ); // Skip category
}
if ( ! empty( $gets_passed['city'] ) ) {
$set_country = true;
unset( $gets_passed['city'] ); // Skip city
}
if ( $set_country && ! empty( $geodirectory->location->country_slug ) ) {
$gets_passed['country'] = $geodirectory->location->country_slug;
}
}
return $gets_passed;
}
add_filter( 'geodir_wpml_url_parameters_gets_passed', 'gd_snippet_20190902_wpml_url_parameters_gets_passed', 20, 3 );
Kiran