Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Do any of these previous solutions work? –  boscho Jun 3 at 5:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.