Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use the “pre_get_posts” action to set WP_Query::is_404 to true. This will result in a “nothing found” sort of response. The actual status returned will still be 200 OK. If you want a true 404 status, you need to hook “pre_handle_404” filter and execute:

    global $wp_query;
    $wp_query->set_404();
    status_header( 404 );

    In both cases you need to confirm the request is not as it should be, otherwise valid requests will also go 404.

Viewing 1 replies (of 1 total)
  • The topic ‘How to make a 404 error in the second nested link’ is closed to new replies.