Why does WordPress remove my variables in the URL?

I am trying to put variables into the URL, which I can then use in my WordPress template. So for example I have created a wordpress template something.php and the page “somepage” with this template. Now in my something.php I am trying to get a variable (for example something.php?variable=whatever) into my script in order to use it there. Im doing this with $_GET[“variable”]. Now everything worked fine on the test server. Now I have put it onto the real server (which is actually the same server, just another copy of wordpress) and there it doesnt work. Opening the URL www.example.com/somepage?variable=whatever will directly lead to www.example.com/somepage. So WordPress is removing every variable in the URL.
Another thing that doesnt work and that probably has to do with the same problem is a search, which I created and which has the post type “post”, not “get”.
What do you think could be the problem, since it worked perfectly fine on the same server with another wordpress copy (same version).

Thank you very much for your help!
phpheini

Related posts

Leave a Reply

1 comment

  1. For one, you can’t call template files directly as you’re doing… If you want the page somepage, you should call it directly, with the query string arguments added after a trailing slash.

    Look into the function add_query_arg() – its a much more bulletproof way of tacking GET variables onto the end of WordPress urls. For example, if you need to call http://www.example.com/somepage with the query string ?variable=whatever, try calling

    add_query_arg( 'variable', 'whatever', 'http://www.example.com/somepage' )

    to get the proper url to use. This guarantees getting the proper url in a format that won’t clash with your rewrite rules.