0

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.

0
function 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.