at the top of the main loop, have_posts() and is_404() are mutually exclusive.
That is true sometimes, but not always. More specifically, it can be false when a non-permalink URL seeks a non-existent post. For example, /?p=-1.
Issue a 404 if a permalink request doesn’t match any posts. Don’t issue a 404 if one was already issued, if the request was a search, or if the request was a regular query string request rather than a permalink request.
Now it makes sense that the single.php template file would check have_posts(). Let the healing begin.
(Are there any documented examples of this bug occurring outside of single.php?)
Scott
/ January 11, 2008I had sort of forgotten about this. I would consider it extra strength usage. Which is good!
So if
/?page_id=9999is a regular query for an invalid page, shouldn’t a 404 be issued, eg, sndbx.org/?page_id=9999? Perhaps we should tag this for Sandbox.Andy
/ January 11, 2008Scott: Confirmed: the page.php template also needs
if ( have_posts() ). Thanks!I was working on a patch to add Sandbox to core when this problem resurfaced. That’s why this post.
I do not know why WordPress does not issue 404s for these queries and use the 404.php template. It is intentional but the reason is undocumented. Anybody know?
Lloyd Budd
/ January 11, 2008Glad you finally come clean
Though I thought you would have fix core to make your lie a truth. (If I recall that was partially done was an example of trying to view a draft when logged out using the Sandbox was uncovered last year)
Milorad
/ January 18, 2008Hacking core to prove yourself right is a completely valid course of action