If POST and PAGE have the same slug then PAGE record will be found even if it has been TRASHed
|Reported by:||lwoods||Owned by:|
I set my permalinks to "postname" and then added a POST to a menu. It turns out I had previously had a PAGE with the same name, but I had TRASHed it. But when I clicked on the menu link I got a "404". I traced the queries and it looks like the query only looks for the slug value and does NOT test for whether the slug name has been trashed.
This can be reproduced by adding a page with the title "Test Page" which will create a slug "test-page". Publish it, then trash it. Now, create a POST with the title "Test Page" and publish it. Go check the database. There are two entries in the database with a post_name of "test-page". Now add a menu entry for the POST "Test Page". When clicking on this menu entry you will get a "404". That's because WP is trying to load the PAGE with a slug of "test-page" and there isn't one.