I managed to run the get_query_var() function. To use the two functions successfully, you need to add query vars to the wordpress query vars array. Here is a sample code.
function add_query_vars_filter( $vars ){ $vars[] = "query_var_name"; return $vars; }
Now you can use get_query_var() and add_query_arg() as follows:
Add var query and value
add_query_arg( array('query_var_name' => 'value'), old_url );
Get the value of var request
$value = get_query_var('query_var_name');
More information and code examples can be found in Codex: get_query_var and add_query_arg
Themba clarence malungani
source share