最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Add spacebar in WP List Table Search

programmeradmin2浏览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.

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.

发布评论

评论列表(0)

  1. 暂无评论