最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - Add spacebar in WP List Table Search

matteradmin7PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far