Manipulate a url string by adding GET parameters

前端 未结 15 2167
旧巷少年郎
旧巷少年郎 2020-11-29 00:50

I want to add GET parameters to URLs that may and may not contain GET parameters without repeating ? or &.

Example:

If I want t

15条回答
  •  广开言路
    2020-11-29 01:20

    In case you are using WordPress you can simply use

        add_query_args(['sort' => 'asc'], 'http:/example.com/?search=news')
    

    Docs https://developer.wordpress.org/reference/functions/add_query_arg/

提交回复
热议问题