urls - Remove All Query Arg

Is there a way to remove all query arg parameter in the URL added via add_query_arg(); without knowing the query key ava

Is there a way to remove all query arg parameter in the URL added via add_query_arg(); without knowing the query key available for removal?

I'm looking for this kind of function remove_query_arg_all(); currently I'm removing the query_arg via preg_match REQUEST_URI, but not sure if it will cause any problem in the future.

Is there a way to remove all query arg parameter in the URL added via add_query_arg(); without knowing the query key available for removal?

I'm looking for this kind of function remove_query_arg_all(); currently I'm removing the query_arg via preg_match REQUEST_URI, but not sure if it will cause any problem in the future.

Share Improve this question asked Apr 20, 2016 at 16:43 nonsensecreativitynonsensecreativity 7626 silver badges20 bronze badges 1
  • Did you try searching stackoverflow ? – Sumit Commented Apr 20, 2016 at 17:09
Add a comment  | 

2 Answers 2

Reset to default 7

You can explode URL by ? and take the first part:

$url = explode( '?', esc_url_raw( add_query_arg( array() ) ) );

$no_query_args = $url[0];

You can do this in one line if your aim is to remove all of the params from the current $_GET

remove_query_arg(array_keys($_GET))

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744857493a4597494.html

相关推荐

  • urls - Remove All Query Arg

    Is there a way to remove all query arg parameter in the URL added via add_query_arg(); without knowing the query key ava

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信