0

Where does is_404() get set?

Looking at the source in query.php:

function is_404() {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
        return false;
    }

    return $wp_query->is_404();
}

which just returns a value already set in $wp_query.

However, if I then set a breakpoint in set_query_var this never gets hit.

1 Answer 1

1

There is a dedicated method for it WP_Query->set_404(). From quick search through code it can be set in WP_Query->parse_query() or WP->handle_404() (note WP, not WP_Query!).

But it can (and sometimes does) get set on query externally, for example by plugin that needs to invalidate specific resource.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.