I came across a weird issue.
Say you access a random url, three or more levels deep:
http://example.com/a/b/c http://example.com/a/b/c/d ...
true. So far so good. But for some reason the last posts are queried.
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND ( wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private' ) ORDER BY wp_posts.post_date DESC LIMIT 0, 5
Which then of course makes
true and so on. Can someone explain this?
What I found out so far:
The reason that only kicks in at three or more levels deep is that before that WP looks for posts and attachments which somehow results in some other behaviour.
It seems that even though WP recognises the request as a 404 at one point it then fetches the most recent posts. With the help from @kaiser and @G.M. I've tracked this down to somewhere from /wp-includes/class-wp.php:608