A client came to me with a strange problem. He’d written and published a post, but when he tried to view it on his site he got a 404-Not Found error.
Usually, when there is a problem with posts or pages disappearing the culprit is permalink-related. Most of the time, a simple click of the update button on the Settings > Permalink page will fix it. Not this time.
I could see no logical reason for the post to be ‘Not Found’. The permalink matched the post slug, there were no kinky characters or spaces. All of the other posts displayed as they should have. A quick switch of the theme back to Twentyten proved useless also, same problem. A look through the rewrite_rules option in the _options table proved fruitless also. Or did it?
I found the post slug within the rewrite_rules option entry; all seemed normal, until I saw this line:
Huh? This was a post, not a page.
Then came the lightbulb moment. What if there’s a page with the same slug as the post? Not supposed to happen, but you never know.
Nothing resembling that title on the pages list.
Ahhhh, the trash can. The WordPress guys and girls had a pretty decent idea when they implemented the trash can. It takes a page or post out of circulation, but still keeps it around just in case.
Keeps it around with the original slug.
Gotcha. Sure enough, in the Pages trash can was a page with the identical slug as the post. Evidently my client had learned how to manipulate post slugs. How he was able to use a slug identical to an existing one is a question I haven’t answered yet.
Permanently delete the trashed page, and as if by magic the post now shows up where it’s supposed to.
Moral of the story: check the trash.