I was able to replace the main query for 404 pages with pre_get_posts but as soon as I point to an existing page, the error changes to 301.
What function should I hook to to change the status to 404 AFTER a page has been found?
The relevant working code is
$query-> set('p' , null); $query-> set( 'page_id' , $some_page_id); $query->set_404(); status_header(404); nocache_headers();
Please, don't suggest using a 404.php page, unless you can explain all the default behavior I should hack to avoid creating one. ( I want to be the one who decides if doing it otherwise is not worth the try, rather than accepting other's limits). Thanks.