WordPress GET and POST parameter names
I just spent 6 hours trying to figure out why I was getting random 404 page not found errors in WordPress when I tried to pass GET parameters in the URL.
I was passing year and month variables to a WP page in the following format: http://mywebsite.com/view-units/?month=1&year=2017 A year of 2016 would work fine. A year of 2017 would give me a 404 error.
I then tried a really simple page like this:
<?php
if( $_GET["fname"] || $_GET["age"] ) {
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>
</body>
</html>
…and it would give me a 404 error as well.
IT TURNS OUT…. Word press has a list of reserved words you can’t use as GET (or POST) parameter names or it will cause “WordPress to respond with a 404 error without any other hint or explanation”.
In both my examples above I had randomly hit upon a reserved name (year and name).