WordPress – Determine whether 404 was *actually* a private page view…

WordPress WP_Query’s get_posts() method takes a somewhat draconian approach to private posts on single and page views and strips them from the results even if you specify you want them with the query parameters. With it, goes the ability to distinguish between private pages and those which are true 404s.

The snippet below overcomes this and allows you to fork the page into two…

Extra bonus points to anyone who points out how I can use an action to direct private posts would-be-404s to another template…

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to LinkedIn Post to StumbleUpon Post to Technorati