Recently, I built one calendar functionality within WordPress. Not thinking too much while building it, I used “month” and “year” as query variable names and added a rewrite rule so that I could keep the same permalink style without having to do the normal question mark variable equals. I tested it for a month or two ahead and a month or two back and it appeared to be working properly.
Later on, when I revisited it, I realized that when attempting to view a different year it gives a “404 page not found” error. After spending much time playing around with the rewrite rule, using query variables in a different manner, I begin to look at the permalink settings page. I tried changing that to a few different choices to see if that was conflicting, and of course, nothing there was causing the issue.
So I began to notice that in most of the permalinks, they have a date set. What if WordPress already uses “month” or “year” in some manner and by me overwriting it, it is not allowing the page to be shown, even though I know that it exists? Lo and behold, that resolved the issue. However, something kind of puzzling to me is that when I do a “get_query_var” for either “month” or “year”, it does not return anything. What might be happening, though, is if either of those are set to anything, then the permalink engine attempts to find that page name in the archive for that year.
In the end I am glad to have found a fix, but I am still not 100% sure as to why. If anyone can shed some light on the subject, I would not mind the lesson.