passing custom query parametrs in URL
-
I have found a few bits and pieces of the answers in this forum but not all the answers. If they are indeed all there and I have missed them, then I apologize.
In any case, here are my questions: I have a custom page that needs to make use of a custom URL parameter like this for example:
https://www.myblog.com/mypage?kk=3
Here “kk” is a custom parameter that my page (“mypage”) makes use of. The page mypage actually executes some custom PHP code (enabled using the EXEC-PHP plugin) and this custom PHP code needs to use the kk parameter to execute properly. This page is something that goes on lots of my WordPress sites and lots of my customers’ WP sites and in most cases in the past, it seems I could just use the $_GET array to get access to parameter “kk” in mypage, e.g.:
$kk=$_GET[‘kk’];
// use $kk hereAlso note that the parameter name ‘kk’ is just one possibility. I use several other possible parameter names like ‘p’ or ‘pp’ or ‘s’ or …
But for sake of clarity in this post, I’ll just refer to it as ‘kk’.The problem is that in some WP installs, it seems that WP does not pass the kk variable in thru $_GET. Has WP changed recently so that newer versions of WP now filter out any parameter in the URL that it has not been explicitly told about before? Which versions of WP have this filtering enabled?
My problem is that I need a very simple way for WP to turn off this filtering of unknown query parameters. I have hundreds of customers with thousands of WP sites and I need to be able to give them a simple way to make sure that any such parameter (could be kk or pa or s or several other possibilities) is NOT ignored by WP but is indeed passed in and available in the $_GET array inside the code for mypage. Is it possible to turn off this filtering?
If it is not possible (or not a good idea), I’d like to be able to make it easy for my customers to get mypage to work properly on their sites. This URL:
https://www.webopius.com/content/137/using-custom-url-parameters-in-wordpress
talks about a simple plugin that a user could install. Then instead of getting the variable from $_GET, mypage would need to get the variable from the global $wp_query->query_vars array. This is OK I suppose but I really would rather make the kk variable available in $_GET so I don’t have to make customers change legacy code on thousands of sites. Is there any way to do this?Again, I need something really easy since the solution is something I will be specifying to my customers who are nonprogrammers. A way of turning off parameter filtering on mypage is great. Or a simple plugin that makes the parameters to mypage available inside mypage would also be great.
Thanks.
- The topic ‘passing custom query parametrs in URL’ is closed to new replies.