In this tutorial we are going to learn How to pass extra variables in URL with WordPress ? We have to pass two variables named domain and price. So we need to use url like
http://localhost/worpress/get-domain/?domain=.in&price=800
http://localhost/worpress/get-domain/?domain=.com&price=1000
http://localhost/worpress/get-domain/?domain=.info&price=750
First we have to create a page name called Get Domain (which will create url http://localhost/worpress/get-domain/), now in Page add add a custom wordpress shortcode
[sp_domain_price]
Now add code give below in your functions.php and check
// domain details
function price_query_vars( $qvars ) {
$qvars[] = 'price';
return $qvars;
}
add_filter( 'query_vars', 'price_query_vars' );
function domain_query_vars( $qvars ) {
$qvars[] = 'domain';
return $qvars;
}
add_filter( 'query_vars', 'domain_query_vars' );
function sp_request_parameter() {
//$parameters = get_query_var( 'price', 1 );
$default="";
if(get_query_var( 'domain', 1 )){
$domain= get_query_var( 'domain', 1 );
}else{
$domain= $default;
}
if(get_query_var( 'price', 1 )){
$price= get_query_var( 'price', 1 );
}else{
$price= $default;
}
$domain=strtoupper($domain);
$string="<h2>First Year ".$domain." Domain Registration Price: Rs. ".$price."</h2>
<p>Register your ".$domain." Domain before someone else does. </p>";
//$price." ".$domain;
return $string;
}
add_shortcode('sp_domain_price', 'sp_request_parameter');



