I would like to add spacebar %20 or + on the redirect URL in the search, how can I do that with the add_query_arg?
function bulk_search() {
$redirect_to = add_query_arg( array( 's' => $_POST['s'] ), $_POST['_wp_http_referer']);
wp_redirect( $redirect_to );
exit();
}
With the function above, if in the search box I keyed in "Hello World" it would return the search with &s=helloworld on the URL instead of &s=hello+world
Thank you in advance.
I would like to add spacebar %20 or + on the redirect URL in the search, how can I do that with the add_query_arg?
function bulk_search() {
$redirect_to = add_query_arg( array( 's' => $_POST['s'] ), $_POST['_wp_http_referer']);
wp_redirect( $redirect_to );
exit();
}
With the function above, if in the search box I keyed in "Hello World" it would return the search with &s=helloworld on the URL instead of &s=hello+world
Thank you in advance.
Share Improve this question asked Apr 9, 2019 at 3:04 Calvin SengCalvin Seng 32 bronze badges1 Answer
Reset to default 0function bulk_search() {
$redirect_to = add_query_arg( array( 's' => urlencode($_POST['s']) ), $_POST['_wp_http_referer']);
wp_redirect( $redirect_to );
exit();
}
Realised by adding urlencode() function would do.