wordpress add query string to url

Solutions on MaxInterview for wordpress add query string to url by the best coders in the world

showing results for - "wordpress add query string to url"
Lilwenn
18 Oct 2016
1PHP$url = 'http://example.com/whatever/?hello=world';
2shapeSpace_add_var($url, 'goodbye', 'nightclub');
Mike
09 May 2018
1PHPfunction shapeSpace_add_var($url, $key, $value) {
2	
3	$url = preg_replace('/(.*)(?|&)'. $key .'=[^&]+?(&)(.*)/i', '$1$2$4', $url .'&');
4	$url = substr($url, 0, -1);
5	
6	if (strpos($url, '?') === false) {
7		return ($url .'?'. $key .'='. $value);
8	} else {
9		return ($url .'&'. $key .'='. $value);
10	}
11}
similar questions
queries leading to this page
wordpress add query string to url