admin管理员组

文章数量:1024668

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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.

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: pluginsAdd spacebar in WP List Table Search