WordPress Adicionar string de consulta ao URL
PHP$url = 'http://example.com/whatever/?hello=world';
shapeSpace_add_var($url, 'goodbye', 'nightclub');
LightSearch
PHP$url = 'http://example.com/whatever/?hello=world';
shapeSpace_add_var($url, 'goodbye', 'nightclub');
PHPfunction shapeSpace_add_var($url, $key, $value) {
$url = preg_replace('/(.*)(?|&)'. $key .'=[^&]+?(&)(.*)/i', '$1$2$4', $url .'&');
$url = substr($url, 0, -1);
if (strpos($url, '?') === false) {
return ($url .'?'. $key .'='. $value);
} else {
return ($url .'&'. $key .'='. $value);
}
}