WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem : Example : http://domain/hotel Now I set value: http://domain/hotel/?tour=hawaii

How i can get value of variable "tour".

share|improve this question

closed as off-topic by s_ha_dum, TheDeadMedic, Wyck, Johannes Pille, toscho Jul 10 '13 at 10:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should be specific to WordPress within defined scope (merely happening in its context, such as generic PHP/JS/HTML/CSS, is insufficient). Might be better asked at Stack Overflow or other appropriate site of Stack Exchange network." – s_ha_dum, TheDeadMedic, Johannes Pille, toscho
If this question can be reworded to fit the rules in the help center, please edit the question.

Its all depend how you have extended your url. The easiest way is by


and other way is by wp_query

global $wp_query;

I think this should help you out.

share|improve this answer
sorry, I'm try but it not work. :( – thai Kont Jul 10 '13 at 7:16

1) $_GET

You could use something like:

if (isset($_GET['tour']) && !empty($_GET['tour'])) 
    $your_var = $_GET['tour'];

Now the variable $your_var is set with "hawaii" when you load the page http://domain/hotel/?tour=hawaii

2) Wordpress Filter

You can also use filter with wordpress.

Here is an other solution : http://www.webopius.com/content/137/using-custom-url-parameters-in-wordpress

share|improve this answer
Thank you. Method 2 work fine in my home page of theme. But when i create blank php page. It not work. – thai Kont Jul 10 '13 at 7:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.