WordPress permalink, stop redirection

First, I’ll say it’s beyond me why you’d want to do this, I really don’t think it’s a good idea, but in any case…

If you look in /wp-includes/canonical.php, you’ll see how WP is fighting you on this. The only way I’m aware of to get around it is to go looking for the post yourself based on the post id query var (which should be set and hopefully correct) and resetting the $wp_query global to whatever is found, then manually setting the status header so a 404 isn’t sent to the browser.

function wpse27871_404_fakeout() {
    global $wp_query;
    if( $wp_query->is_404 && get_query_var('p') ):
        $this_query = new WP_Query( 'p='.get_query_var('p') );
        if( $this_query->post_count !== 0 ):
            $wp_query = $this_query;
            status_header(200);
        endif;
    endif;
}
add_action('wp', 'wpse27871_404_fakeout');