Prevent private post 404

According to the Content Visibility page, Private posts are visible only to those with sufficient permission levels. WordPress doesn’t expose them to non-logged-in users at all, hence (presumably) the 404.

If you want to display a limited preview to non-members, instead of setting the post to Private, you could try something like this:

add_filter( 'the_content', 'wpse101968_preview' );
function wpse101968_preview( $content ) {
    if( is_single() ) {
        if( ! is_user_logged_in() ) {
            $content = get_the_excerpt();
        }
    }
    return $content;
}

And then your non-logged-in visitors will see the post’s excerpt instead of the entire post. You can customize the excerpts, too, so that they see only what you want them to see.

References

Codex:

Leave a Comment