This is an odd problem that I have never run into before with WordPress.
I have a site, permalinks enabled.
The url can be http://mysite.com/page-name/?anyParamName=testing
then when I use print_r($_GET);
or echo $_GET["anyParamName"]
I get an empty array or nothing respectively.
A pure PHP file works fine so its not a server issue. Does WordPress do anything with rewiring the get params? Really puzzled by this.
For custom parameters you should register them with WordPress:
Then the value of ‘anyParamName’ can be found with
get_query_var
know that this is old question, but we can freely access any post/get parameters inside ‘init’ hook, (before WordPress changes it) and that is documented here, look:
n order to be able to add and work with your own custom query vars that you append to URLs (
eg: "http://example.com/some_page/?my_var=foo"
– for example using add_query_arg()) you need to add them to the public query variables available to WP_Query. These are built up when WP_Query instantiates, but fortunately are passed through a filter ‘query_vars’ before they are actually used to populate the $query_vars property of WP_Query.So, to expose your new, custom query variable to WP_Query hook into the ‘query_vars’ filter, add your query variable to the $vars array that is passed by the filter, and remember to return the array as the output of your filter function. See below:
For further details please have a look
https://codex.wordpress.org/Function_Reference/get_query_var
I had the same problem:
The right page was loaded (not the folder), but the _GET parameters were empty.
I renamed the folder (in the file system) and the _GET array is now getting as expected.